I already made a table with the specific colors i want the bricks to change to but i cant quite do the loop.
while wait(120) do part.BrickColor = table[math.random(1,#table)] end -- this is the loop a friend helped me with and then he told me to try with for and pairs.
Thanks in advance.
If the parameters in the table are BrickColor values, then that script should work fine! Be sure you defined the variable 'table' as well as 'part'! The for loop is used when you want to go through multiple objects/multiple parameters in a table. Say if you wanted a bunch of parts to become that brick color:
table = {"Really red", "Really blue"} while wait(120) do for i,v in pairs(script.Parent:GetChildren()) do if v:IsA("Part") then v.BrickColor == BrickColor.new(table[math.random(#table)]) end end end
The above script goes through every child that's a member of the script's parent, checks if it's a part, then changes all of their BrickColors! Your script was a bit confusing, so if you have any questions, be sure to comment!