Color3:Lerp() not working

Hi forum,

So I want to make my brick lerping through the colors red and orange using Color3.fromRGB while the brick exist, but when I run the game, the colors of the brick stays the same.

I have tried using this code but it didn’t work:

while Meteor do
	for i = 0,1, 0.1 do
		print("Start Lerping")
		Meteor.Color = Meteor.Color:Lerp(Color3.fromRGB(255, 0, 0), i)
		Meteor.Color = Meteor.Color:Lerp(Color3.fromRGB(255, 140, 0), i)
	end
	wait()
end

Try this:

while Meteor do
	for i = 1, 0.1 do
		print("Start Lerping")
		Meteor.Color = Meteor.Color:Lerp(Color3.fromRGB(255, 0, 0), i)
		Meteor.Color = Meteor.Color:Lerp(Color3.fromRGB(255, 140, 0), i)
	end
	task.wait()
end

the i should always start from 0 and end at 1 when you want to use i as a alpha number for lerping

Oh sorry I typed it wrong.

while Meteor do
	for i = 0, 1, 0.1 do
		print("Start Lerping")
		Meteor.Color = Meteor.Color:Lerp(Color3.fromRGB(255, 0, 0), i)
		Meteor.Color = Meteor.Color:Lerp(Color3.fromRGB(255, 140, 0), i)
	end
	task.wait()
end
1 Like

It still didn’t work but thank you for trying at least.

You need to move the wait one line up, otherwise the for loop will finish instantly.

This isn’t a linear interpolation due to a couple of factors, but if it looks good that’s all that matters.

The for loop will never be exactly 1 due to rounding errors.