What is the :lerp function?

Here is another example of using Lerp. We loop through, starting at 0.1, and ending at 0.9, increasing by 0.1 each time. Then I create a new part each loop and position it that much between the two parts.

local Part1 = game.Workspace:WaitForChild("Part1")
local Part2 = game.Workspace:WaitForChild("Part2")

for i = 0.1, 0.9, 0.1 do
	local Part = Instance.new("Part", workspace)
	Part.Anchored=  true
	Part.CFrame = Part1.CFrame:Lerp(Part2.CFrame, i)
	local Suface = script.SurfaceGui:Clone()
	Suface.TextLabel.Text = i
	Suface.Parent = Part
end

Result:

As you can see, lerping by 0.1 creates a part very close to “Part1”, lerping by 0.5 creates a part in between, and lerping 0.9 creates a part very close to Part2

48 Likes