so that is the code of a single instance:

	var instancedCoin = coin.instance()
	instancedCoin.position.x = 300
	instancedCoin.position.y = 400
	get_tree().get_root().get_node("MainScene2D").add_child(instancedCoin)

How can I create an array of these please? Having ans placing different coins nodes

I developed this solution but it is not a multidimensional array:

	var cpos = []
	cpos.append(50)
	cpos.append(300)
	for id in range(0,cpos.size()):
		var instancedCoin = coin.instance()
		instancedCoin.position.x = cpos[id]
		instancedCoin.position.y = 400
		get_tree().get_root().get_node("MainScene2D").add_child(instancedCoin)

So in this case I can store only one info and I should create as many arrays as many datas I need to store like, position x, position y, value Is there a way to do that using only one array?

I don't quite understand what you want to achieve.

Right now you are creating an array that looks like this [50,300]. And then you are looping 2 times, in each loop you create a instance of coin and then set its x position to id, id is 50 the first time and 300 the second time.

If you want to manually insert each coin position into the array you can do an 2d array:

var cpos = [ [50,300] , [70,150] ] # this array holds 2 other arrays, yo don't need the spaces

now for getting the value 50 I need to go to the first index of cpos:

print(cpos[0])  result:  [50,300]
print(cpos[1])  result: [70,150]

to get the position of X then you need to get the index of that second array
print(cpos[0][0]) result: 50
print(cpos[0][1]) result: 300

print(cpos[1][0]) result: 70
print(cpos[1][1]) result: 150

if this is confusing you can instead store a Vector2 inside the array

var cpos = [Vector2(50,300), Vector2(70,150)]

then you could do:

for index in cpos.size(): 
var instancedCoin = coin.instance()
instancedCoin .position = cpos[index]

if you want more coins add more Vector2 to the cpos array

no ok, I have to dynamically add more coins to the array and each coin contains more info, like posx, posy, value, playerto

So I need to store 4 datas dynamically, how can I do that please?

Just add them to a Node2D in the scene. This way you can always get them as an array via $Node2D.get_children().

2 years later