How to get and set any inspector property using GDScript

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

i have seen some solution regarding this. But those solution are not working maybe due to they are for older godot versions.
I want to get and set properties of a node using GDScript. Properties in Inspector like get and set texture, get and set position, get and set size of node, etc.

Is there a common function which we can call in GDScript to get and set properties of a node easily ?

:bust_in_silhouette: Reply From: kidscancode

You can get and set any property of a node using its name. You can see its name when you hover over the property in the Inspector, or you can look at the API reference for that node, which has a list of its properties.

For example, to get the “Position” property:


and to set it:

position = Vector2(100, 100)

If you want to access a property on another node, use . notation:

$Sprite.texture = load("res://image.png")

I highly recommend reading the official tutorial, which shows much of this essential functionality: