Please god tell me theres a more efficient way to do this
local par = script.Parent modes = {"FallDown","Spiral","Generic","SlideOpen","BlockFall","CollumnFall","Firework","FallUp","CheckerBoard","FallingCheckerboard"} while wait() do local picked = modes[math.random(1,#modes)] if picked == "FallDown" then -- Fall Down local color = BrickColor.Random() par.p1.BrickColor = color par.p2.BrickColor = color par.p3.BrickColor = color par.p4.BrickColor = color par.p5.BrickColor = color par.p6.BrickColor = color par.p7.BrickColor = color par.p8.BrickColor = color par.p9.BrickColor = color par.p10.BrickColor = color par.p11.BrickColor = color par.p12.BrickColor = color end end
You can use a for loop
to quickly iterate over the children of "par" to save yourself some time by not having to struggle with changing each child's brickcolor separately.
local par = script.Parent modes = {"FallDown","Spiral","Generic","SlideOpen","BlockFall","CollumnFall","Firework","FallUp","CheckerBoard","FallingCheckerboard"} while wait() do local picked = modes[math.random(1,#modes)] if picked == "FallDown" then -- Fall Down local color = BrickColor.Random() for _, v in pairs (par:GetChildren()) do if v:IsA("Part") or v:IsA("UnionOperation") then -- Checking to see if the child is a part / union, filters out any other instances v.BrickColor = color -- if part passes through check, change the brickcolor end end end end
Questions / comments? Feel free to message me and I'll answer them as soon as possible. If you are satisfied with the answer I provided, please upvote me. Thanks! - Kyo
You could loop through 'par' and change the children.
local par = script.Parent modes = {"FallDown","Spiral","Generic","SlideOpen","BlockFall","CollumnFall","Firework","FallUp","CheckerBoard","FallingCheckerboard"} while wait() do local picked = modes[math.random(1,#modes)] if picked == "FallDown" then -- Fall Down local color = BrickColor.Random() for i, v in pairs(par:GetChildren()) do if v:IsA("Part") then v.BrickColor = color end end end end