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

Not Quite Getting Lerping/Not Flipping Player? [SOLVED]

Asked by 6 years ago
Edited 6 years ago

Hello everyone! :D It's me again with a question!

Today I tried to use lerp, but it's not working out as I had hoped. ;/ I'm not sure what I'm supposed to be doing either.

What I'm trying to do is get a player to flip. Yup, that's it. lol But they're not flipping for some reason, and there's no errors being returned; I'm at a snag. :c

diz iz my code

local hrp = Workspace.TheeDeathCaster:FindFirstChild('HumanoidRootPart')
if hrp then
    hrp.Anchored = true
    local EndCFrame = hrp.CFrame*CFrame.Angles(math.rad(360),0,0)
    local StartCFrame = hrp.CFrame
    for i = 1, 20 do
        hrp.CFrame = StartCFrame:lerp(EndCFrame, i/20)
        print('CFrame:', StartCFrame:lerp(EndCFrame, i/20)) -- Prints the cframe though. >.>
        wait(1/20)
    end
    hrp.Anchored = false
end

Anyone know what I'm doing wrong? I also looked up questions on the website, but I don't quite understand them. :P (The answers, that is)

EDIT1

Rotation is being accounted for, but I had to set up the code differently; however, the player "teleports" when the lerp gets to a certain point.

Workspace.TheeDeathCaster.HumanoidRootPart.Anchored = true
local StartCFrame = Workspace.TheeDeathCaster.HumanoidRootPart.CFrame
for i = 360, 1, -5 do
    local EndCFrame = StartCFrame*CFrame.Angles(math.rad(i),0,0)
    Workspace.TheeDeathCaster.HumanoidRootPart.CFrame = StartCFrame:lerp(EndCFrame, i/360)
    print(StartCFrame:lerp(EndCFrame, i/360))
    wait(1/13.37)
end
Workspace.TheeDeathCaster.HumanoidRootPart.Anchored = false

EDIT2: SOLVED I rearranged a lot of stuff, and I finally got it working, although it's not as 100% smooth as I had hoped it to be.

0
Try using char:SetPrimaryPartCFrame() instead of setting hrp's CFrame directly. Amiaa16 3227 — 6y
0
Same result occurred. >-> TheeDeathCaster 2368 — 6y
0
I just did a bit of testing, and it's the rotating that's not working correctly; how come it's not accounting for the rotation? TheeDeathCaster 2368 — 6y
0
EDIT: Rotation is being accounted for now, but the player "teleports" when it gets to a specific point. I'll reflect this in EDIT1. TheeDeathCaster 2368 — 6y

Answer this question