So I made a animation in Studio and then made a script so it could be a Idle Animation, but it loops and then after a while it stops.
I made prints so it could detect if the speed of the player is over 0 and if its 0 or under it, it never prints that the speed is over 0.
My script:
local animation = game.ReplicatedStorage.ReaperIdleAnimation
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local loadedAnim = hum:LoadAnimation(animation)
loadedAnim.Looped = true
hum.Running:Connect(function(speed)
if speed > 0 then
print("hi")
loadedAnim:Stop()
else
print("bye")
loadedAnim:Play()
end
end)
--Output is always bye
I just added an elseif instead of an else and it worked for me.
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local idleAnimation = Instance.new("Animation")
idleAnimation.AnimationId = "rbxassetid://4657922943"
local loadedAnimation = humanoid:LoadAnimation(idleAnimation)
loadedAnimation.Looped = true
humanoid.Running:Connect(function(speed)
if speed > 0 then
print ("RUNNING")
loadedAnimation:Stop()
elseif speed == 0 then
print("STOPPED")
loadedAnimation:Play()
end
end)