Attempt to index number with 'Lerp'?

Hi, I tried using the script below to smoothly change the value of angle by 5, but when i run the code i get this error message:
image
I don’t see what i am doing wrong here…

My script:

for i = 0,1,.01 do
	wait()
	angle = angle:Lerp(angle + 5, i)
end

Angle is just an integer value.

Thanks :smiley:

3 Likes

Lerp only works on values like Vector3s, Color3 etc not on numbers.

You’re basically doing

3:Lerp(5, 0.4)

A soltuion is to create a custom function that does it for you

local function Lerp(num, goal, i)
  return num + (goal-num)*i
end

Lerp(1, 2, 0.5) -- 1.5
22 Likes