Animation did not work well when I press E

Hey there guys! I was working with animation keybind and this problem suddenly happened. As you can see in the video, the script worked well when it changed the “AnimationId” but the idle animation only play when the character moves.


This is my script:

local player = script.Parent
local UIS = game:GetService("UserInputService")
local equip = Enum.KeyCode.E
local Animate = player:WaitForChild("Animate")
local idle = Animate.idle.Animation1
local humanoid = player:WaitForChild("Humanoid")
local debounce = true
-----
function fight()
	Animate.idle.Animation1.AnimationId = "rbxassetid://7440040752"
	Animate.idle.Animation2.AnimationId = "rbxassetid://7440040752"
	Animate.walk.WalkAnim.AnimationId = "rbxassetid://7443648246"
end
function idle()
	Animate.idle.Animation1.AnimationId = "rbxassetid://180435571"
	Animate.idle.Animation1.AnimationId = "rbxassetid://180435792"
	Animate.walk.WalkAnim.AnimationId = "rbxassetid://180426354"
end
-----

local ready = script.Ready
local ReadyStance = humanoid:LoadAnimation(ready)
UIS.InputBegan:Connect(function(input,isTyping)
if isTyping then return end
	if input.KeyCode == equip and debounce == true then

		fight()
		ReadyStance:Play()
		humanoid.WalkSpeed = 0
		wait(1)
		humanoid.WalkSpeed = 10
		debounce = false
		print("equip")
	elseif input.KeyCode == equip and debounce == false then
		idle()
		humanoid.WalkSpeed = 16
		print("unequip")
		debounce = true
		end
end) 

I’ve tried countless of conditions to change the result but none of them works, so I wrote this post hoping you guys help me dealing with this problem. Thanks you guys so much for reading!

Probably the Animation Priority is lower than the default idle’s animation priority. Check that.

I changed the priority of the custom idle animation to “idle” but it didn’t make any differences though

Only create a Animation on workspace (example), put the id on AnimationId and make

-- This is only a example script, you need to change to work in your script
local anim = player.Humanoid:LoadAnimation(workspace.Animation)
anim:Play()
wait(time)
anim:Stop()