Help with Making Lerp Module Script

So over the last couple days I’ve attempted to make a simple Lerp Module as a community resource and I’ve came upon an error. In the Output you get no message at all.So what’s happening is when I’m trying to test the module from a normal script the lerp doesn’t work in the intended way. The part stays at the start goal and then automatically teleports to the end goal.

Here is my Module’s code:

local LerpModule = {}

function LerpModule:SmoothCFrameLerp(PartToLerp : PVInstance, GoalCFrame : CFrame, TimeBeforeLerp : number)
	wait(TimeBeforeLerp)
	for i = 0,1, .01 do
		PartToLerp.CFrame = PartToLerp.CFrame:Lerp(GoalCFrame, i)
	end
end

function LerpModule:SmoothColorLerp(PartToLerp : PVInstance, GoalColor : Color3, TimeBeforeLerp : number)
	wait(TimeBeforeLerp)
	for i = 0,1, .01 do
		PartToLerp.Color = PartToLerp.Color:Lerp(GoalColor, i)
	end	
end

function LerpModule:SmoothPositionLerp(PartToLerp : PVInstance, GoalPosition : Vector3, TimeBeforeLerp : number)
	wait(TimeBeforeLerp)
	for i = 0,1, .01 do
		PartToLerp.Position = PartToLerp.Position:Lerp(GoalPosition, i)
	end
end

function LerpModule:SmoothOrientationLerp(PartToLerp : PVInstance, GoalOrientation : Vector3, TimeBeforeLerp : number)
	wait(TimeBeforeLerp)
	for i = 0,1, .01 do
		PartToLerp.Orientation = PartToLerp.Orientation:Lerp(GoalOrientation, i)
	end
end

return LerpModule

Thanks for all help. All help is appreciated. Thanks!

Tomroblox54321

1 Like

The wait function should be inside the for loop

1 Like

Thanks. I think that might work I’m not sure why I didn’t put it in the for loop. Will update you ASAP!

1 Like

Thanks a lot @IlyasTawawe that did work but now it’s really clunky like it’s at an increment of 0.1 unlike mine at 0.001. Thanks

1 Like

Thanks so much for the help what I ended up doing is removing the TimeBeforeLerp function to the module.

1 Like