What I have tried so far is iterating through the parts and adding a small amount of hue value to each part and when their hue value reaches max (1) it resets back to 0.
However this does not look smooth at all and the parts somehow end up having a very similar colour after a bit.
Here’s a picture of my code :
Note: The for loop is under a render stepped event.
Since color in computers is normally on a scale of 0-255, but Roblox measures colors from 0-1, the colors would be smoother if you added 1/255 instead of 0.1. Hope this makes sense
local basePart = workspace:WaitForChild("Part")
for i = 1, 20 do
-- create a row of parts
local newPart = basePart:Clone()
newPart.Color = Color3.fromHSV(i / 20, 1, 1)
newPart.Position = basePart.Position + Vector3.new(2 * i, 0, 0)
newPart.Parent = workspace.parts
-- same value as color above, 0-1
local hValue = Instance.new("NumberValue")
hValue.Name = "hValue"
hValue.Value = i / 20
hValue.Parent = newPart
end
game:GetService("RunService").Heartbeat:Connect(function(deltaTime)
-- just advance each color by deltaTime
for i,v in pairs(workspace.parts:GetChildren()) do
-- probably faster than converting RGB to HSV, i just did it because i don't like dealing with conversion
local hComponent = v.hValue.Value + (deltaTime / 25)
-- roll the value over when too high but *smoothly*
if hComponent >= 1 then
hComponent = hComponent - 1
end
-- set the values
v.Color = Color3.fromHSV(hComponent, 1, 1)
v.hValue.Value = hComponent
end
end)
Give the parts an individual value for Hue, and roll it over when required. Your error was most likely h = h + 0.1 and setting h to 0 instead of h - 1 when rolling it back under 1
edit: sorry if this is spoonfeeding, i tried to explain what little there was to explain using code comments
I’m assuming your issue isnt the color rather than the sequence not going in order. This is because a for loop won’t order them for you nor will a model or folder. I would use a numerical loop. and name the parts corresponding to their position in the sequence. Then you can index from the table made for the numerical loop the next part in the sequence.
Forgive me for not giving an example as I am on my smartphone.
Hi my friend told me using ipairs takes the parts in order of creation/parenting. Ive tested this and it seemed to work but I will still consider your suggestion.