### Godot version

4.0-rc6

### System information

Fedora 37, Mesa Intel ADL GT2

### Issue description

Code that works as expected at runtime fails with Nil references to (assigned) exported vars in the editor:

![tool_global_position_error](https://user-images.githubusercontent.com/364501/222031460-ffb1ecbd-5175-4a42-8470-25285ba5f821.png)


### Steps to reproduce

Try to access the `global_position` of a `Node3D` that's assigned to an exported var.

See that it works at runtime.

See that it errors in the editor with:

> Invalid get index 'global_position' (on base: 'Nil').

### Minimal reproduction project

[tool_test.zip](https://github.com/godotengine/godot/files/10856640/tool_test.zip)

List<Pair<StringName, Variant>> old_state;
						if (node->get_script_instance()) {
							node->get_script_instance()->get_property_state(old_state);
						}
						node->set(snames[nprops[j].name], props[nprops[j].value], &valid);
						
						for (const Pair<StringName, Variant> &E : old_state) {
							node->set(E.first, E.second);
						}
					} else {
						Variant value = props[nprops[j].value];
						if (value.get_type() == Variant::OBJECT) {
							
							Ref<Resource> res = value;
							if (res.is_valid()) {
								if (res->is_local_to_scene()) {
									
									
									
									
									
									
									
									if (n.instance >= 0) {
										Ref<Resource> node_res = node->get(snames[nprops[j].name]);
										if (node_res.is_valid()) {
											node_res->copy_from(res);
											node_res->configure_for_local_scene(node, resources_local_to_scene);
											value = node_res;