How to use the set function to set the value of an object in an array by index?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By dbiton
:warning: Old Version Published before Godot 3 was released.

How can i set the value of a specific object in an array on a different script?
Something like

-Script 1
var array = [0,0,0]

-Script 2
func _ready():
get_node(“~”).set(“array”[0], 1)

I have tried different syntax, yet none seem to work.
Is this possible?

:bust_in_silhouette: Reply From: Zylann

Why use the set function if you can just do this?

get_node("~").array[0] = 1

If you really want to use set, you have to get it and change it (because it’s a reference type)

get_node("~").get("array")[0] = 1