Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Error lerping cframe how would I lerp?

	local endpoint = player.Character.HumanoidRootPart.CFrame
	for i = 0, 1, 0.1 do
		local lerp = cloud.Position:lerp(endpoint.lookVector * 10,  i)
		wait(2)
	end

Just like always the lerp wiki gives zero explanation on how to lerp properly, it seems they want to scare me off.

i wanted the brick to move 10 studs in front of the hrp but it says CFRAME EXPECTED, GOT VECTOR3

help please??

1 answer

Your script should work. If you are lerping a Vector3, then the first argument is a Vector3, which it is, but if this errors, try using TweenService. It is easier and better for interpolation.

TweenService solution

local endpoint = player.Character.HumanoidRootPart.CFrame
local TweenService = GetService(_TweenService_)
local tween = TweenService:Create(cloud,TweenInfo.new(20,Enum.EasingSyle.Linear),{Position = endpoint.p + (endpoint.lookVector * 10)})
tween:Play() -- The animation would last 20 seconds. To change that, change the 20 on line 3.

Lerp method solution

local endpoint = player.Character.HumanoidRootPart.CFrame
local start = cloud.Position
for i = 0, 1, 0.1 do
	local lerp = start:Lerp(endpoint.p + (endpoint.lookVector * 10),  i)
	cloud.Position = lerp -- to move the cloud.
	wait(2)
end

This discussion is preserved as it was. New answers, comments, and votes are closed.