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

How do I fix my Motor6D walk cycle that loops incorrectly?

Asked by 5 years ago
Edited 5 years ago
function WalkThere()
    if walking == false then
    return
    end
    doubleframes = 0
repeat
    if walking == false then
    break
    end
    wait()
    doubleframes = doubleframes + 1
    Torso["Neck"].C0 = Torso["Neck"].C0:Lerp(CFrame.new(0, 1, 0) * CFrame.Angles(math.rad(-260), math.rad(180), 0), 0.1)
    Torso["Right Shoulder"].C0 = Torso["Right Shoulder"].C0:Lerp(CFrame.new(1, 0.5, 0) * CFrame.Angles(0, math.rad(90), math.rad(-35)), 0.1)
    Torso["Left Shoulder"].C0 = Torso["Left Shoulder"].C0:Lerp(CFrame.new(-1, 0.5, 0) * CFrame.Angles(0, math.rad(-90), math.rad(-35)), 0.1)
    Torso["Left Hip"].C0 = Torso["Left Hip"].C0:Lerp(CFrame.new(-1, -1, 0) * CFrame.Angles(math.rad(-30), math.rad(-90), 0), 0.1)
    Torso["Right Hip"].C0 = Torso["Right Hip"].C0:Lerp(CFrame.new(1, -1, 0) * CFrame.Angles(math.rad(35), math.rad(90), 0), 0.1)
    RootPart.RootJoint.C0 = RootPart.RootJoint.C0:Lerp(CFrame.new(0, -0.3, 0) * CFrame.Angles(math.rad(80), math.rad(180), 0), 0.1)
until doubleframes == 15
    doubleframes = 0
repeat
    if walking == false then
    break
    end
    wait()
    doubleframes = doubleframes + 1
    Torso["Neck"].C0 = Torso["Neck"].C0:Lerp(CFrame.new(0, 1, 0) * CFrame.Angles(math.rad(-260), math.rad(180), 0), 0.1)
    Torso["Right Shoulder"].C0 = Torso["Right Shoulder"].C0:Lerp(CFrame.new(1, 0.5, 0) * CFrame.Angles(0, math.rad(90), math.rad(0)), 0.1)
    Torso["Left Shoulder"].C0 = Torso["Left Shoulder"].C0:Lerp(CFrame.new(-1, 0.5, 0) * CFrame.Angles(0, math.rad(-90), math.rad(0)), 0.1)
    Torso["Left Hip"].C0 = Torso["Left Hip"].C0:Lerp(CFrame.new(-1, -1, 0) * CFrame.Angles(math.rad(0), math.rad(-90), 0), 0.1)
    Torso["Right Hip"].C0 = Torso["Right Hip"].C0:Lerp(CFrame.new(1, -1, 0) * CFrame.Angles(math.rad(0), math.rad(90), 0), 0.1)
    RootPart.RootJoint.C0 = RootPart.RootJoint.C0:Lerp(CFrame.new(0, 0, 0) * CFrame.Angles(math.rad(80), math.rad(180), 0), 0.1)
until doubleframes == 10
    doubleframes = 0
repeat
    if walking == false then
    break
    end
    wait()
    doubleframes = doubleframes + 1
    Torso["Neck"].C0 = Torso["Neck"].C0:Lerp(CFrame.new(0, 1, 0) * CFrame.Angles(math.rad(-260), math.rad(180), 0), 0.1)
    Torso["Right Shoulder"].C0 = Torso["Right Shoulder"].C0:Lerp(CFrame.new(1, 0.5, 0) * CFrame.Angles(0, math.rad(90), math.rad(35)), 0.1)
    Torso["Left Shoulder"].C0 = Torso["Left Shoulder"].C0:Lerp(CFrame.new(-1, 0.5, 0) * CFrame.Angles(0, math.rad(-90), math.rad(35)), 0.1)
    Torso["Left Hip"].C0 = Torso["Left Hip"].C0:Lerp(CFrame.new(-1, -1, 0) * CFrame.Angles(math.rad(35), math.rad(-90), 0), 0.1)
    Torso["Right Hip"].C0 = Torso["Right Hip"].C0:Lerp(CFrame.new(1, -1, 0) * CFrame.Angles(math.rad(-30), math.rad(90), 0), 0.1)
    RootPart.RootJoint.C0 = RootPart.RootJoint.C0:Lerp(CFrame.new(0, -0.3, 0) * CFrame.Angles(math.rad(80), math.rad(180), 0), 0.1)
until doubleframes == 15
if walking == true then
    WalkThere()
end
end

hboogy.Humanoid.Running:Connect(function()
    if walking == false then
        walking = true
        print("Walking")
        WalkThere()
    elseif walking == true then
        walking = false
        print("NotWalking")
        StandThere()
    end
end)

^ relevant lines of code

I've basically done everything i could with the doubleframes variable that wouldn't break this part of the script but the 2nd lerp repeat only works once until i stop, and start to walk again

here's a gif of what i mean

https://gyazo.com/5f5ccbb74a172a256c573579e62b74ec

i am at a loss so please help me here and ask if you need anything extra

Answer this question