Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I make the animation play only when moving?

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

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

2 comments

0

could u show me how i would go about doin that?

0

Sure. But can you wait until tommorow? If so, thank you for your patience

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.