Hey,
I have an issue with my sprint script, essentially when i stand still and hold left shift and then start moving and then i stop moving but keep holding shift, the animation still plays
my code :
local p = game.Players.LocalPlayer
local c = p.Character
local h = c:WaitForChild('Humanoid')
local u = game:GetService('UserInputService')
local held = false
local stepped = game:GetService('RunService').Stepped
local sprintanim = Instance.new('Animation', script)
sprintanim.AnimationId = 'rbxassetid://6496505792'
local a = h:WaitForChild("Animator")
local strack = a:LoadAnimation(sprintanim)
local sprinting = Instance.new("BoolValue", h)
sprinting.Name = 'Sprinting'
function sp(inputObject, gameProcessed)
if inputObject.KeyCode == Enum.KeyCode.LeftShift then
held = true
if held == true and h.MoveDirection.magnitude>=0 then
h.WalkSpeed = 30
strack:Play()
sprinting = true
if held == true and h.MoveDirection.magnitude == 0 and strack.IsPlaying then
strack:Stop()
end
if held == true and h.MoveDirection.magnitude == 0 or c.HumanoidRootPart.Velocity == 0 then
if strack.IsPlaying then
strack:Stop()
end
repeat wait() until
h.MoveDirection.magnitude>0
strack:Play()
end
end
end
end
function ps(inputObject, gameProcessed)
if inputObject.KeyCode == Enum.KeyCode.LeftShift then
held = false
sprinting = false
if held == false and sprinting == false then
h.WalkSpeed = 16
strack:Stop()
end
end
end
u.InputBegan:connect(sp)
u.InputEnded:connect(ps)

2 comments
Are there any errors in the output? (You can open the output by going to: View>Output
No, everything works fine except what i said in the post