Haven’t been in studio for a hot minute, I tried looking for others with a similar problem but found no working fix
I’m using the default Animate script that’s slightly modified + a separate run script
When I stop running on the client, my player seems fine, but if I look on the server he’s stuck running while idle. Any idea on what’s causing this and how to fix it?
Extra part in the animate script:
--1
runEvent.Event:Connect(function()
if Figure:WaitForChild("HumanoidRootPart").Velocity.Magnitude > 0.02 then
playAnimation("run", .1, Humanoid)
elseif Figure:WaitForChild("HumanoidRootPart").Velocity.Magnitude < 0.02 then
stopAllAnimations()
end
end)
relevant part of the run localscript:
local function sprint(active)
if exhausted then return end -- we can't run because we're exhausted!
if active then
humanoid.WalkSpeed = 20
animate.walk.WalkAnim.AnimationId = "rbxassetid://16616476248"
animate.run.RunAnim.AnimationId = "rbxassetid://16616476248"
runEvent:Fire()
task.wait(.05)
humanoid.CameraOffset = Vector3.new(0, -.45, -1)
else
humanoid.WalkSpeed = 8
animate.walk.WalkAnim.AnimationId = "rbxassetid://16609497245"
animate.run.RunAnim.AnimationId = "rbxassetid://16609497245"
runEvent:Fire()
task.wait(.05)
humanoid.CameraOffset = Vector3.new(0, .1, -.45)
end
running = active
end
UIS.InputBegan:Connect(function(input, gp)
if gp then return end
if input.KeyCode == sprintKey and root.Velocity.Magnitude > 0.02 then
sprintHeld = true
if stamina > 0 then
sprint(true)
end
end
end)
UIS.InputEnded:Connect(function(input, gp)
if gp then return end
if input.KeyCode == sprintKey then
sprintHeld = false
sprint(false)
end
end)
humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
if root.Velocity.Magnitude < 0.02 then
sprint(false)
runEvent:Fire()
end
end)
staminaInst:GetPropertyChangedSignal("Value"):Connect(function()
staminaEvent:Fire(stamina)
end)
local db = false
local lastStoppedTime = 0
game:GetService("RunService").RenderStepped:Connect(function(dt)
if stamina > 100 then stamina = 100 end
if running then
if stamina > 0 then
stamina = math.clamp(stamina - 16 * dt, 0, 100)
else
sprint(false)
exhausted = true
humanoid.WalkSpeed = 4
end
lastStoppedTime = tick()
elseif stamina < 100 and tick() - lastStoppedTime > 2 then
if stamina > 20 then
exhausted = false
exhaustedEvent:FireServer(false)
humanoid.WalkSpeed = 8
if sprintHeld then
sprint(sprintHeld)
end
end
stamina = math.clamp(stamina + 8 * dt, 0, 100)
end
if exhausted then
exhaustedEvent:FireServer(true)
if not breathingSfx.IsPlaying then
breathIn:Play()
breathingSfx:Play()
end
tiredTween:Play()
elseif not exhausted then
if breathingSfx.IsPlaying then
breathOut:Play()
breathOut.Completed:Wait()
breathingSfx:Stop()
end
notTiredTween:Play()
end
if sprintHeld and root.Velocity.Magnitude < 0.02 then
running = false
end
staminaEvent:Fire(stamina)
end)