Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Color Lerp doesn't work properly?

local newColor = Color3.new(math.random(255), math.random(255), math.random(255))
for i=0,1,0.1 do
    script.Parent.Color = script.Parent.Color:lerp(newColor, i)
    wait()
end

Instead of doing a transition, it does this garbage instead.: https://www.youtube.com/watch?v=qHoCi8t3p3g

3 comments

0

replace wait() with wait(.01)

0

im confused as to what do you want it to do? are you complaining about the fact that it is doing it really fastly or do you want it to go from color to color without passing multiple different colors? if the latter, use tweens, not lerp, and do Color3.fromRGB, because Color3 takes values from 0 to 1.

0

@F_F That won't do anything, @radusavin I already figured it out, but thanks for your help, the problem is that i used color3.new instead of Color3.fromRGB, habit from other game engine. and using lerp is much simpler than tweens

1 answer

✓ Accepted answer

Color3.new takes float from 0 to 1. You should use Color3.fromRGB instead if you're trying to use RGB values for parameters:

local newColor = Color3.fromRGB(math.random(255), math.random(255), math.random(255))
for i=0,1,0.1 do
    script.Parent.Color = script.Parent.Color:lerp(newColor, i)
    wait()
end

https://wiki.roblox.com/index.php?title=API:Color3

This discussion is preserved as it was. New answers, comments, and votes are closed.