I can't seem to access a script attached to a scene after instancing it.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By chandlerfromfriend

First time poster so please let me know if I am doing anything wrong.
I cant seem to access the script attached to my scene when instancing it.

I am getting the error message: "Invalid set index of ‘id’ (on base ‘Sprite’) with value type ‘int’.

This is a function that I call in the ready function of my main project:

> func spawn_structure(struct, pos, rot, item): 	
>   print(struct.scene)
> 	var new_structure  = load(struct.scene).instance()
> 	print(new_structure) 	
>   new_structure.id = 1

a struct is a custom class that stores id, scene, among other things
the print statements print as follows →
“res://prefabs/stand.tscn” and “[Sprite:1298]”
So I know the scene is instanced properly.
I have attached an image of the stand.tscn scene and the script that is attached to it.

enter image description here

I’m sure this is something and easily fixed but I can’t seem to figure it out and would very much appreciate any help
Thanks

When you click on the script icon next to the floor node in the scene tree, does it open a script which has an id variable?

Zylann | 2020-02-28 21:04

Yes, it opens the ‘structure.gd’ script that’s open there.

chandlerfromfriend | 2020-02-29 02:31

I don’t know what’s wrong. Do you have any project to share reproducing the problem?

Zylann | 2020-02-29 02:42