Hey. I'm doing a crouch system and I want to have 2 animations for it: one that plays while the player is not moving and one that plays while the player is moving. I've checked HumanoidStateType and there is a state called running, but nothing about standing/idle. My script doesn't run the moving animation, just the standing one. This is what I have so far:
local UserInputService = game:GetService("UserInputService")
local character = game.Players.LocalPlayer.Character
local humanoid = character.Humanoid
animation = Instance.new("Animation")
animation.Name = "Moving"
animation.AnimationId = "http://roblox.com/asset/?id=2163761498"
animTrack = humanoid:LoadAnimation(animation)
standinganim = Instance.new("Animation")
standinganim.Name = "Standing"
standinganim.AnimationId = "http://roblox.com/asset/?id=1293954626"
standinganimTrack = humanoid:LoadAnimation(standinganim)
UserInputService.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.C then
if humanoid.StateChanged == Enum.HumanoidStateType.Running then
animTrack:Play()
print("moving") --this doesn't work so it doesn't print "moving"
else
animTrack:Stop()
standinganimTrack:Play()
print("not moving") --This prints "not moving" even when I'm moving
end
end
end)
UserInputService.InputEnded:Connect(function(key)
if key.KeyCode == Enum.KeyCode.C then
animTrack:Stop()
standinganimTrack:Stop()
end
end)
I assume that the Running State is not the state I am looking for so... help?

1 comment
Forgot an equal. It works :D Thanks!