- Edited
I'm trying to change the variable of an instance after creating it through code but just get the error message 'invalid set index 'number' (on base: 'KinematicBody2D') with value of type 'int'.
var instance = preload("res://Scenes/Units/Test/Unit1.tscn").instance()
add_child(instance)
instance.position = Vector2(1100, 600)
instance.name = "Bob"
citizen_number += 1
instance.number = citizen_number
pass
Maybe I'm misunderstanding how instances work, but aren't they essentially like copies of a node (including the script) that can be modified separately? I'd appreciate any help :)