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

Custom Animation Help?

Asked by 10 years ago

So, I have a script. I know the problem. I use a function that fires if the player moved or stopped. But I also have a function that makes the player jump. Disabling the moving. But if your moving while jumping and you land it glitches.

wait(.5)
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
player.Character["Animate"]:remove()
local welds = {player.Character.Torso["Left Shoulder"],player.Character.Torso["Right Shoulder"],player.Character.Torso["Left Hip"],player.Character.Torso["Right Hip"],player.Character.HumanoidRootPart.RootJoint,player.Character.Torso["Neck"]}
local default = {player.Character.Torso["Left Shoulder"].C1,player.Character.Torso["Right Shoulder"].C1,player.Character.Torso["Left Hip"].C1,player.Character.Torso["Right Hip"].C1,player.Character.HumanoidRootPart.RootJoint.C1,player.Character.Torso["Neck"].C1}
--key
--weld[1] = Left Arm
--weld[2] = Right Arm
--weld[3] == Left Leg
--weld[4] == Right Leg
local jumping = false

function onwalking(speed)
    if speed > 0 and jumping == false
        then
        script.Walking.Disabled = false
        script.Walking2.Disabled = false
else
    if jumping == false
        then
        script.Walking.Disabled = true
        script.Walking2.Disabled = true
        welds[1].C1 = default[1]
        welds[2].C1 = default[2]
        welds[5].C1 = default[5]
        welds[6].C1 = default[6]
        welds[3].C1 = default[3]
        welds[4].C1 = default[4]         
        welds[1].DesiredAngle = 0
        welds[2].DesiredAngle = 0
        welds[3].DesiredAngle = 0
        welds[4].DesiredAngle = 0
        end
    end
end

function onjump()
    jumping = true
        script.Walking.Disabled = true
        script.Walking2.Disabled = true
        welds[1].C1 = default[1]
        welds[2].C1 = default[2]
        welds[5].C1 = default[5]
        welds[6].C1 = default[6]
        welds[3].C1 = default[3]
        welds[4].C1 = default[4]         
        welds[1].DesiredAngle = 0
        welds[2].DesiredAngle = 0
        welds[3].DesiredAngle = 0
        welds[4].DesiredAngle = 0
    welds[1].C1 = default[1]*CFrame.Angles(-80,0,0)
    welds[2].C1 = default[2]*CFrame.Angles(-80,0,0)
end

function landed(type)
    if type == Enum.HumanoidStateType.Landed
        then
        jumping = false
        print("Landed")
        welds[1].C1 = default[1]
        welds[2].C1 = default[2]
        welds[5].C1 = default[5]
        welds[6].C1 = default[6]
        welds[3].C1 = default[3]
        welds[4].C1 = default[4]         
        welds[1].DesiredAngle = 0
        welds[2].DesiredAngle = 0
        welds[3].DesiredAngle = 0
        welds[4].DesiredAngle = 0
    end
end

player.Character.Humanoid.Running:connect(onwalking)
player.Character.Humanoid.Jumping:connect(onjump)
player.Character.Humanoid.StateChanged:connect(landed)

1 answer

Log in to vote
1
Answered by 10 years ago

I would use this plugin. It works very good. (It's made by ROBLOX.)

Click here

0
That is not what I asked. User#5978 25 — 10y
0
Hey, It's better than taking your time making a script. You don't got to be rude. Grenaderade 525 — 10y
0
;d I fixed it. Just added 4 KeyDown() and KeyUp() functions to check if anyone of those were being held, if so then it moved. User#5978 25 — 10y
Ad

Answer this question