Statements in fuction need to go out function!

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)

Thats not really my point if you change amount in the for i,v will it change the amount outside right?

It will, yes, but you’re still missing a closing bracket after the lol:GetChildren()

It will, yes.

In Lua, you construct a for loop with the syntax:

for ... do
end

So, you need to apply the correct keywords in your code blocks:

for k, v in pairs(iter:Method()) do
    -- some code
end

Does that clarify things?