### Godot version

4.0.beta17

### System information

windows 10, nvidia graphics

### Issue description

When creating a typed array from another base array, if the base array was gotten from get_tree().get_nodes_in_group(), you cannot create a typed array assigning a script different from null, otherwise the resulting array will be filled with nulls.

![image](https://user-images.githubusercontent.com/5783414/216142311-1eded30c-e8ff-4a2b-aa5a-61ae5cafce13.png)


### Steps to reproduce

See attached video:

https://user-images.githubusercontent.com/5783414/216142187-82af9900-d490-4d6d-b4cc-9d776d8b8cc9.mp4



### Minimal reproduction project

[TypedArrayConstructorDoesntWorkWithScriptsWhenUsingGetNodesInGroup.zip](https://github.com/godotengine/godot/files/10560863/TypedArrayConstructorDoesntWorkWithScriptsWhenUsingGetNodesInGroup.zip)

### WorkAround

Instead of using the output of get_tree().get_nodes_in_group() directly, the user can join it with an empty array
```gdscript
[]+get_tree().get_nodes_in_group()
```
and it will work as expected.
return _p;
}
Array::Array(const Array &p_from, uint32_t p_type, const StringName &p_class_name, const Variant &p_script) {
	_p = memnew(ArrayPrivate);
	_p->refcount.init();
	set_typed(p_type, p_class_name, p_script);
	assign(p_from);
}
void Array::set_typed(uint32_t p_type, const StringName &p_class_name, const Variant &p_script) {
	ERR_FAIL_COND_MSG(_p->read_only, "Array is in read-only state.");
	ERR_FAIL_COND_MSG(_p->array.size() > 0, "Type can only be set when array is empty.");
	ERR_FAIL_COND_MSG(_p->refcount.get() > 1, "Type can only be set when array has no more than one user.");
	ERR_FAIL_COND_MSG(_p->typed.type != Variant::NIL, "Type can only be set once.");
	ERR_FAIL_COND_MSG(p_class_name != StringName() && p_type != Variant::OBJECT, "Class names can only be set for type OBJECT");
	Ref<Script> script = p_script;
	ERR_FAIL_COND_MSG(script.is_valid() && p_class_name == StringName(), "Script class can only be set together with base class name");
	_p->typed.type = Variant::Type(p_type);
	_p->typed.class_name = p_class_name;
	_p->typed.script = script;
	_p->typed.where = "TypedArray";
}
bool Array::is_typed() const {
	return _p->typed.type != Variant::NIL;
}
bool Array::is_same_typed(const Array &p_other) const {
	return _p->typed == p_other._p->typed;
}
uint32_t Array::get_typed_builtin() const {