When testing the animation stays playing when the player isn’t running on the server.
I need help on why this script doesn’t work on the server but does on client:
local db = false
game.ReplicatedStorage.Run.OnServerEvent:Connect(function(player, status)
local loadanim = player.Character.Humanoid:LoadAnimation(game.ReplicatedStorage.RunAnim)
if status == "began" and player.Character:FindFirstChild("Stamina").Value >= 14 and player.Character.Humanoid.MoveDirection ~= Vector3.new(0, 0, 0) then
player.Character.Running.Value = true
player.Character.Humanoid.WalkSpeed = 25
loadanim:Play()
if not db then
db = true
while player.Character.Stamina.Value >= 17.5 do
wait()
if player.Character.Stamina.Value <= 17.5 then
loadanim:Stop()
player.Character.Humanoid.WalkSpeed = 15
player.Character.Running.Value = false
loadanim:Stop()
print("STOSPTOPSTOPSTOPSOTPSOTPOSTPSOT")
loadanim:Stop()
end
if player.Character.Humanoid.MoveDirection == Vector3.new(0, 0, 0) then
print("not")
player.Character.Running.Value = false
player.Character.Humanoid.WalkSpeed = 15
loadanim:Stop()
break
end
if player.Character.Stamina.Value >= 18 and player.Character.Running.Value == true and player.Character.Humanoid.MoveDirection ~= Vector3.new(0, 0, 0) then
player.Character.Stamina.Value = player.Character.Stamina.Value - 2.5
wait(.5)
end
end
db = false
end
else
loadanim:Stop()
player.Character.Running.Value = false
player.Character.Humanoid.WalkSpeed = 15
end
end)