Error: Object not inherited from GDScript, trying to assign to TypedArray

Hmm okay this is weird. What happens when you remove the type from the array?

I removed the type hints on both array and the error still presists

But theres no error when the resource extends CardEffect instead of EffectMove?

1 Like

Yes exactly

This similar issue suggests to clear the cache and restart the engine, because the cache might be corrupted:

So delete the .godot folder and start the engine again. Maybe do a backup of the folder, eventhough that shouldnt be neccessary. Note that this will lead to the engine having to reimport all the assets which might take a bit, depending on the number of assets

1 Like

Thanks for the idea.
Sadly it still doesn’t work.

hm okay. Inside the .godot folder is a “global_script_class_cache.cfg”-file. Open it and look for your EfffectMove-class

I came into this problem too, I removed the type definition in array( like this in your code:

@export var cards: Array[CardResource] = []

// I changed it into this
@export var cards: Array = []

and it works
hope this can help you

2 Likes

I fixed it by forcing the variable in the has() argument to be of the typed variable.

Enemy extends Entity

target is Entity

data.enemy_occupants is Array[Enemy]

has_target just a bool

Creates the error:

if data.enemy_occupants.has(target):
has_target = true

Error no longer present:

if target is Enemy:

if data.enemy_occupants.has(target):
has_target = true

I had a similar issue to that of the OP as well, and @crene_chu ‘s solution worked for me, so thanks for posting!

I wanted to add that I ended up being able to add my type back in by providing a type hint to the ResourceLoader like this (using the OP’s types):

var cr = ResourceLoader.load(file_path, “CardResource”)

Hello, I also encountered this issue. After investigating, I found the root cause: some scene files (.tscn) or resource files (.tres) in the project had invalid UID references — they were likely manually hardcoded. The solution was: delete those files (or delete the corresponding .uid files) and let Godot regenerate the correct UIDs. That resolved the problem.