Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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( ) ?

1 comment

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.

1 answer

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

1 comment

0

Here is the issue, the IntValue are inside of bricks, so when I try that it does not work.

This discussion is preserved as it was. New answers, comments, and votes are closed.