Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Error lerping cframe how would I lerp?

Asked by 6 years ago
    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

Log in to vote
0
Answered by
UgOsMiLy 1074 Moderation Voter
6 years ago

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
Ad

Answer this question