Help With Array.append

Godot Version

4.4

Question

I’m trying to add a variable to my script using Array.append. However, when I try to print the array, it shows nothing the first time the function is run but after that it works. Can anyone help me?

Here is my code
if $"../..".coins>=100: var amount_to_take = 100 $"../..".coins-=amount_to_take create_investment(amount_to_take) var value_creation=Value invests.append(value_creation) print(invests)

Hi!

I just tried this code and it works perfectly:

var arr: Array[int] = []
	
arr.append(1)
print(arr)
	
arr.append(2)
print(arr)

# Output:
[1]
[1, 2]

Could you share your code with a cleaner formatting, and more context (like more of the code file)?

2 Likes