I'd like for all of the parts within a single model to change color at the same time. I currently have this script inside every single part that needs to change color but it just gets messy and they don't always change in sync.
while true do script.Parent.Color = Color3.new(0,204,255) wait(1.1) script.Parent.Color = Color3.new(0,255,0) wait(1.1) script.Parent.Color = Color3.new(255,255,0) wait(1.1) script.Parent.Color = Color3.new(255,0,0) wait(1.1) script.Parent.Color = Color3.new(153,0,153) wait(1.1) script.Parent.Color = Color3.new(0,0,255) wait(1.1) end
If I could get help calling all of the children within a model and changing them together that would help me so much.
Here you go, with some extra indirection and parametrisation thrown in:
local model = script.Parent local delta = 1.1 -- time between colour changes --list of colors to cycle through local colors = { Color3.new(0,204,255), Color3.new(0,255,0), Color3.new(255,255,0), Color3.new(255,0,0), Color3.new(153,0,153), --EDIT: missing comma Color3.new(0,0,255) } -- infinite loop while true do --loop through each of the colors for _, c in pairs(colors) do --for each color, set all of the parts in the model to that color for _,p in pairs(model:GetChildren()) do --make sure this child is a part if p:IsA("BasePart") then p.BrickColor = BrickColor.new(c) end end wait(delta) --wait 'delta' seconds before next color end end
Insert into the model whose parts you want to change color. Edit the list of colors
or the time delta
to tweak the animation and cycling through the colors.