So I’m trying to tell a varible to change in a if state ment or in this case for i,v but it won’t cahnge so has anyone an awnser how to do this and not with adding values in some thing just like this I’m trying it:
local amount = 0
for i,v in pairs(lol:GetChildren()
amount += v.Value
end
print(amount) -- this will == to 0
The issue is your syntax. Also, you should be checking that v has property Value, just in case!
local amount: number = 0
for i, v in pairs(lol:GetChildren()) do
if v and v.Value and typeof(v.Value) == "number" then
amount += v.Value
end
end
print(amount)