Idle anim | Crowl script

I am making crawl script but idle anim do not work. How can i fix it?

local UIS = game:GetService("UserInputService")
local char = script.Parent
local hum = char:WaitForChild("Humanoid")
local anim = hum:LoadAnimation(script:WaitForChild("Animation"))
local anim2 = hum:LoadAnimation(script:WaitForChild("AnimationIdle"))
local isCrawling = false

UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.C then
		if not isCrawling then
			hum.WalkSpeed = 6
			isCrawling = true
			hum:UnequipTools()
			anim:Play()
			game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
		else
			hum.WalkSpeed = 16
			anim:Stop()
			isCrawling = false
			game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
		end
	end
end)


if isCrawling == true and hum.MoveDirection.Magnitude == 0 then -- idle anim
	anim2:Play()
end

This is not repeatedly checking if iscrawling is true.

You can look into HumanoidStates to check when the player is moving, or idle to set iscrawling to true or false.

https://developer.roblox.com/en-us/api-reference/event/Humanoid/StateChanged

you can try this , because as 1000knoves said. that last code doesnt checks if player is crawling.
you should use

hum.Running:Connect(function(speed)
if speed < 2 and isCrawling == true then
anim2:Play()
end
end)

hope this helps!

2 Likes