#How do I stop a running animation from playing when the player isn't moving
1 messages · Page 1 of 1 (latest)
local player = game:GetService('Players').LocalPlayer
local rig = script.Parent
local humanoid = rig:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://83314579185606"
local animationTrack = animator:LoadAnimation(animation)
local run = "run"
local Idle = "Idle"
local duration = nil
UIS.InputBegan:Connect(function(input,gameproc)
if input.KeyCode == Enum.KeyCode.LeftShift then
animationTrack.Looped = true
animationTrack:Play()
humanoid.WalkSpeed = 60
animationTrack:Play()
for _,animation in ipairs(animator:GetPlayingTracks()) do
if animation.Name == "Run" then
animation.Priority = Enum.AnimationPriority.Action2
end
end
end
end)
UIS.InputEnded:Connect(function(input,gameproc)
if input.KeyCode == Enum.KeyCode.LeftShift then
animationTrack:Stop()
humanoid.WalkSpeed = 16
animationTrack.Looped = false
end
end)```
ill use a one time running script instead of it being universal
if humanoid.MoveDirection.Magnitude == 0 then return end what it means is that it checks if the player is moving, if not, then it cancels the rest f=of the script in the event