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

How would I make the animation play only when moving?

Asked by
BLOYZO 0
7 years ago

Hi I need help with this running script Right now it plays when you press shift even if you're standing still how would you make it so it only plays it when you are moving around and stuff?

repeat
    wait()
until game.Players.LocalPlayer

player = game.Players.LocalPlayer
character = player.Character
game.Workspace:WaitForChild(game.Players.LocalPlayer.Name)
if not character then
    character = player.CharacterAdded:wait()
end

Mouse = player:GetMouse()
humanoid = character:WaitForChild("Humanoid")
s = humanoid:LoadAnimation(script.Animation)

Mouse.KeyDown:connect(function(key)
    for i, v in pairs(game.Players:GetChildren()) do
    if Enum.KeyCode.LeftShift then
            s:Play()
            humanoid.WalkSpeed = 30
        end
Mouse.KeyUp:connect(function(key)
    if Enum.KeyCode.LeftShift then
            s:Stop()
            humanoid.WalkSpeed = 16
end 
end)
end
end)

2 answers

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

I guess the easiest way is while you hold shiFt that it plays animation if the humanoid's move coordinates aren't 0, 0, 0

0
could u show me how i would go about doin that? BLOYZO 0 — 7y
0
Sure. But can you wait until tommorow? If so, thank you for your patience BakonBot 26 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

make a function to check if the torso position is equal and if so just stop the animation. You would need to put a wait command though.

Answer this question