Need help with animations

Script:

	local Humanoid = Player.Character.Humanoid
	local AnimHold = Instance.new("Animation")
	AnimHold.AnimationId = "http://www.roblox.com/Asset?ID=".. "7171945000"

	local AnimRun = Instance.new("Animation")
	AnimRun.AnimationId = "http://www.roblox.com/Asset?ID=".. "7171695596"

	local AnimCrouch = Instance.new("Animation")
	AnimCrouch.AnimationId = "http://www.roblox.com/Asset?ID=".. "7172079149"



	local AnimHoldTrack = Humanoid:LoadAnimation(AnimHold)

	local AnimRunTrack = Humanoid:LoadAnimation(AnimRun)

	local AnimCrouchTrack = Humanoid:LoadAnimation(AnimCrouch)

	print(Type)
	if Type == "Walking" then
		AnimCrouchTrack:Stop()
		AnimRunTrack:Stop()
		wait()
		AnimHoldTrack:Play()
	elseif Type == "Run" then
		AnimCrouchTrack:Stop()
		AnimHoldTrack:Stop()
		wait()
		AnimRunTrack:Play()
	end

Problem: Run and walking work when I press it for the first time, but it does not work when I press it for the second time.

Did you set the Animation Priority correctly when exporting your animation? I always forget, gives weird results

image

Yes, i did. I don’t think it’s because of this reason

From your code only thing i can tell is that Type is not defined. Its general good practice to not use the word “type” or “Type”. Those are most of the time build-in syntax components which you will overwrite

Okay i did.i made with local script.

The other option is to check for typos just letting you know

I don’'t know if this makes a difference but maybe give those instances a parent.

	local Humanoid = Player.Character.Humanoid
	local AnimHold = Instance.new("Animation", Humanoid)
        local AnimRun = Instance.new("Animation", Humanoid)
--        etc.