Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I iterate/loop through an IntValue in a brick?

Asked by
Seyfert 90
7 years ago

Here is the structure Model > Brick (x100, I have 100 or so bricks in the model) > Int Value (there is an int value in each brick)

I try something like this,

local blah = game.Workspace.Model:GetChildren() for i, v in pairs(blah) do if v.IntValue.Value == "0" then v.IntValue.Value = 1 v.Name = "Done" end

end

However the int value never gets changed, it seems that the for i, v in pairs only iterates through the bricks and not what is inside of the bricks. Do I need to do another for loop? If so, what would I put inside of pairs( ) ?

0
Your code should be working from what I've seen. Maybe one of the bricks doesn't contain an IntVal, use an 'if' statement to check for the IntVal and see if it works. PreciseLogic 271 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

You check an integer value with a string value so it may not work properly try something like this:

local blah = game.Workspace.Model:GetChildren()
for _,v in pairs(blah) do
    if v.IntValue.Value == 0 then
        v.IntValue.Value = 1
        v.Name = "Done"
    end
end
0
Here is the issue, the IntValue are inside of bricks, so when I try that it does not work. Seyfert 90 — 7y
Ad

Answer this question