Hello. I was trying to script a color-changing brick from what I’ve learned from scripting.
When I tested it out, it doesn’t work.
Script:
local rgb = script.Parent
while true do
for _, PartsInModel in ipairs(rgb:GetChildren()) do
PartsInModel = Color3.new(1, 0, 0)
wait(0.05)
for _, PartsInModel in ipairs(rgb:GetChildren()) do
PartsInModel = Color3.new(1, 0.25098, 0)
wait(0.05)
for _, PartsInModel in ipairs(rgb:GetChildren()) do
PartsInModel = Color3.new(1, 0.317647, 0)
wait(0.05)
for _, PartsInModel in ipairs(rgb:GetChildren()) do
PartsInModel = Color3.new(1, 0.45098, 0)
wait(0.05)
end
local rgb = script.Parent
while true do
wait()
for _, PartsInModel in ipairs(rgb:GetChildren()) do
if PartsInModel:IsA("Part") then
PartsInModel.Color = Color3.new(1, 0, 0)
wait(0.05)
end
end
end
Also, you forgot the end in for loops.
Oh, you also want to check if it’s a Part considering you have a Part and a Script in the Model.
local rgb = script.Parent
while true do
for _, PartsInModel in ipairs(rgb:GetChildren()) do
PartsInModel = Color3.new(1, 0, 0)
wait(0.05)
end
for _, PartsInModel in ipairs(rgb:GetChildren()) do
PartsInModel = Color3.new(1, 0.25098, 0)
wait(0.05)
end
for _, PartsInModel in ipairs(rgb:GetChildren()) do
PartsInModel = Color3.new(1, 0.317647, 0)
wait(0.05)
end
for _, PartsInModel in ipairs(rgb:GetChildren()) do
PartsInModel = Color3.new(1, 0.45098, 0)
wait(0.05)
end
end