Hello,

I’m quite new in programming and Godot too, I have a for loop for my array, and I want to check a condition in this loop, but it tells me and error.
« Invalid set index '8' (on base: 'Array') »

for x in array.size():
		if       array[x].has_method("get_active_material"):
			print("erase ",array[x].name)
			array.erase(array[x])

I want to see if the nodes in the array has the array in order to sort them. And keep the nodes that I only need.

Thank you.

for x in array.size()
should be:
for x in range(array.size())

array.erase(array[x]) is a problem. Don't add or remove array elements while you're looping through the array. It messes up the looping.

ah I see, thank you much for your help !