0 votes

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

in Engine by (12 points)

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?

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

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

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.