So basically I have a model with a disco floor in it, all the parts inside of it except for one is called "DiscoFloor" the other is called "DiscoScreen", it only is lighting up "DiscoScreen" and I thought it would light up all of them, can someone fix this? Here is my code
local floors = script.Parent:GetChildren() for _,p in pairs(floors) do while true do if p:IsA("Part") then p.Color = Color3.new(math.random(), math.random(), math.random()) wait(.5) end end end
I have a simple but effective way to fix it. 1st, name all the Discop Floor parts with a number at the end. (Part1, Part2, etc.) Place this Folder into game.Workspace
and name it 'GameScriptService'. Insert a script into it and name the script 'DiscoFloor'. Type the following:
local num = 1 local color1 = Color3.fromRGB(0, 255, 0) local color2 = Color3.fromRGB(0, 0, 255) while true do local parts = game.Workspace.DiscoFloor:GetChildren() --change if you need to for i = 1,#parts do if num == 1 then if parts[i].Name == "Part1" or parts[i].Name == "Part3" then --Add more if necessary. This may not be the simplest way to do it, but it's the only way I know right now. parts[i].Color = color1 else parts[i].Color = color2 end num = 2 else if parts[i].Name == "Part1" or parts[i].Name == "Part3" then --Add more if necessary. parts[i].Color = color2 else parts[i].Color = color1 end num = 1 end end end
If this doesn't work, let me know and I'll try something else.
I know what caused your problem. You gave while true do
so it will forever go on looping the same brick. The script I gave below will change the color of every part and set it to random color every second.
Just rewrite the whole script as:
while true do for _,p in pairs(script.Parent:GetChildren()) do if p:IsA("Part") then p.Color = BrickColor.random() end end wait(1) end
I hope that helps :D