Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Color Lerp doesn't work properly?

Asked by 5 years ago
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

0
replace wait() with wait(.01) F_F 53 — 5y
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. radusavin366 617 — 5y
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 Azure_Kite 885 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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

Ad

Answer this question