Nvm, I found a solution myself, it might now be the smoothest but I'm fine with it.
local items = {}
for index, descendant in pairs(script.Parent.Model:GetDescendants()) do
if descendant.Name == "Part" then
table.insert(items, descendant)
end
end
function positify(val)
if val < 0 then
return -val
else
return val
end
end
while true do
local newR = math.random(255) / 255
local newG = math.random(255) / 255
local newB = math.random(255) / 255
local running = true
while running do
for i, v in pairs(items) do
if v.Color.r > newR then
v.Color = Color3.new(v.Color.r - 1 / 255, v.Color.g, v.Color.b)
elseif v.Color.r < newR then
v.Color = Color3.new(v.Color.r + 1 / 255, v.Color.g, v.Color.b)
end
if v.Color.g > newG then
v.Color = Color3.new(v.Color.r, v.Color.g - 1 / 255, v.Color.b)
elseif v.Color.g < newG then
v.Color = Color3.new(v.Color.r, v.Color.g + 1 / 255, v.Color.b)
end
if v.Color.b > newB then
v.Color = Color3.new(v.Color.r, v.Color.g, v.Color.b - 1 / 255)
elseif v.Color.b < newB then
v.Color = Color3.new(v.Color.r, v.Color.g, v.Color.b + 1 / 255)
end
if positify(newR - v.Color.r) <= 1 / 255 then
if positify(newG - v.Color.g) <= 1 / 255 then
if positify(newB - v.Color.b) <= 1 / 255 then
running = false
end
end
end
end
wait()
end
wait(math.random(0.95, 1.05))
end
2 comments
You can check out tweening. It will make the shifting even smoother.
sorry, I'm quite new to tweening. Do you know how to do it for the code I put in the question?