How to change value of variable of a scene through code?

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

I’m sorry if the question seems super trivial and obvious, but I’m new to Godot and I searched through the forum and the web and couldn’t find an answer to the problem.

I created an instance of a scene (with a ColorRect as its head node) in another Scene’s script. It works well so far, but I couldn’t find how to change its parameters, specifically its position.

I tried the following code but it returned “Invalid get index ‘position’ (on base: ‘ColorRect’).”

extends ColorRect

export (PackedScene) var PriceTag

func _ready():
	var pricetag = PriceTag.instance()
	pricetag.position.x = 50
	owner.move_and_slide()
	
	add_child(pricetag)

It’s pretty difficult to infer the expected syntax without proper code completion.

I’d love if someone could show me how to change a scene’s parameters through code.

Thanks in advance.

:bust_in_silhouette: Reply From: Vrzasq

Hi,

ColorRect is a Control item it has its position inside different propert

piercetah.rect_position.x = 50

Should work