i need help with a sprinting script. when i toggle sprint the animation plays but when i toggle it off the animation still plays and while being completely still , it still plays. How do i fix this? (i am new to this im sry ;-;)
here is the script
local player = game.Players.LocalPlayer repeat wait() until player.Character local char = player.Character local hum = char.Humanoid local running = false local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(Input, Chat) if Input.KeyCode == Enum.KeyCode.LeftControl and not Chat and hum.Health >= 1 then if running == false then hum.WalkSpeed = 28 running = true
local AnimTrack = Instance.new("Animation") AnimTrack.AnimationId = "rbxassetid://5119179090" local Anim = char.Humanoid:LoadAnimation(AnimTrack) Anim:Play()
elseif running == true then
hum.WalkSpeed = 16
running = false
end
end
end)

2 comments
Put the animtrack at the top of your script, then call Anim:Stop() when you want it to be stopped.
its not working ;-; can you give example im very new at this ;-;