How do I make a idle crouch and walking crouch animation play?

I’m making a crouch script with my R15 animations, I have a crouch idle and crouch walk animation. I only figured out how to make a single animation play, but how do I make it so when I’m not moving the idle animation plays and if I walk the walking animation plays?

This is the current script

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local Animate
local Humanoid = player.Character:FindFirstChild(‘Humanoid’)

mouse.KeyDown:Connect(function(Key)
if Key == “q” then
local Animation = Instance.new(“Animation”, player.Character)
Animation.AnimationId = “rbxassetid://3968672841”
Animate = Humanoid:LoadAnimation(Animation)
Animate:Play()
end
end)

mouse.KeyUp:Connect(function(Key)
if Key == “q” then
Animate:Stop()
end
end)

how it looks ingame:
https://gyazo.com/7d6b1bb0ff3d141e6310f341a4f6f995

9 Likes

Make use of Humanoid.Running. Movement animations are based upon detecting when a Humanoid is moving, while an Idle animation is usually just playing it on the fly.

If you require accurate switching between animations, make use of GetState. Upon crouching, use GetState to determine if a Humanoid is moving or not and play the correct animation. From there, the rest of your code work can take effect: idle animation for no movement and running animation for movement.

32 Likes