I made a Run Animation script and a animation for it. The script works exactly how I want it except the script plays while the player isn't move. I don't want it too run while the player isn't moving. Is there a way I can do this?
local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()
local sprinting
local humanoid = player.Character:WaitForChild("Humanoid")
local animationTrack = humanoid:LoadAnimation(game.StarterPlayer.StarterPlayerScripts.LocalScript.Animation)
UIS.InputBegan:Connect(function(input, procccesed, isTyping)
if not procccesed then
if isTyping then
return
end
if input.KeyCode == Enum.KeyCode.LeftShift then
sprinting = not sprinting
if sprinting then
player.Character.Humanoid.WalkSpeed = 30
animationTrack:Play()
else
player.Character.Humanoid.WalkSpeed = 16
animationTrack:Stop()
end
end
end
end)
