Not all animations plays

As the title says, I am only able to play one animation (The one with the F keybind) while the others don’t play.
I don’t get any errors in the output, so if a smart scripter would help me find the problem then i would be happy:))

local player = game.Players.LocalPlayer
local UserInputService = game:GetService("UserInputService")
repeat wait() until player.Character and player.Character.Parent ~= nil
local humanoid = player.Character:WaitForChild("Humanoid")
local mouse = player:GetMouse()

local animB = Instance.new("Animation")
animB.AnimationId = "http://www.roblox.com/asset/?id=12965021674"

local animG = Instance.new("Animation")
animG.AnimationId = "http://www.roblox.com/asset/?id=12997920786"

local animF = Instance.new("Animation")
animF.AnimationId = "http://www.roblox.com/asset/?id=12848925231"

local playAnimB = humanoid:LoadAnimation(animB)
local playAnimG = humanoid:LoadAnimation(animG)
local playAnimF = humanoid:LoadAnimation(animF)

local animPlaying = nil

mouse.KeyDown:connect(function(key)
	if key == "k" then
		-- Check if the player has a tool equipped or is seated, or if left ALT key is not being held down
		if player.Character:FindFirstChildWhichIsA("Tool") or humanoid.Sit or not UserInputService:IsKeyDown(Enum.KeyCode.LeftAlt) then
			return  -- Exit the function without playing the animation
		end

		if animPlaying == playAnimG then
			playAnimG:AdjustSpeed(1)
			playAnimG:Stop()
			animPlaying = nil
		else
			if animPlaying then
				animPlaying:AdjustSpeed(1)
				animPlaying:Stop()
			end
			playAnimG:Play()
			animPlaying = playAnimG
		end
	elseif key == "f" then
		-- Check if the player has a tool equipped or is seated, or if left ALT key is not being held down
		if player.Character:FindFirstChildWhichIsA("Tool") or humanoid.Sit or not UserInputService:IsKeyDown(Enum.KeyCode.LeftAlt) then
			return  -- Exit the function without playing the animation
		end

		if animPlaying == playAnimB then
			playAnimB:AdjustSpeed(1)
			playAnimB:Stop()
			animPlaying = nil
		else
			if animPlaying then
				animPlaying:AdjustSpeed(1)
				animPlaying:Stop()
			end
			playAnimB:Play()
			animPlaying = playAnimB
		end
	elseif key == "g" then
		-- Check if the player has a tool equipped or is seated, or if left ALT key is not being held down
		if player.Character:FindFirstChildWhichIsA("Tool") or humanoid.Sit or not UserInputService:IsKeyDown(Enum.KeyCode.LeftAlt) then
			return  -- Exit the function without playing the animation
		end

		if animPlaying == playAnimF then
			playAnimF:AdjustSpeed(1)
			playAnimF:Stop()
			animPlaying = nil
		else
			if animPlaying then
				animPlaying:AdjustSpeed(1)
				animPlaying:Stop()
			end
			playAnimF:Play()
			animPlaying = playAnimF
		end
	end
end)

The code looks okay, but there might be a few reasons why the animation is not playing. Here are some things you can try:

  1. Check if the animation is actually loading by printing out the animation objects. You can do this by adding the following code after creating the animations:
print(animB.Name)
print(animG.Name)
print(animF.Name)

This should print out the three animation objects in the output window. If any of them are nil, it means that the animation failed to load.

  1. Check if the animation is playing at all. You can do this by adding the following code after playing the animation:
print(playAnimB.IsPlaying)
print(playAnimG.IsPlaying)
print(playAnimF.IsPlaying)

This should print out true or false depending on whether the animation is playing or not.

  1. Check if the animation is being interrupted by another animation. You can do this by checking the animPlaying variable. If it’s not nil, it means that another animation is already playing and needs to be stopped before the new animation can start.

Tried all of these to no avail, the only animation that prints something out is AnimG which is the one that has always been working:((

That means the id is wrong or the animation is deleted. (AnimF and AnimB)

Just tried making all of the animation IDs to the same, still only the AnimG that works while the others do nothing

Try this! (EDITED)

local player = game.Players.LocalPlayer
local UserInputService = game:GetService("UserInputService")
repeat wait() until player.Character and player.Character.Parent ~= nil
local humanoid = player.Character:WaitForChild("Humanoid")
local mouse = player:GetMouse()

local animB = Instance.new("Animation")
animB.AnimationId = "http://www.roblox.com/asset/?id=12965021674"

local animG = Instance.new("Animation")
animG.AnimationId = "http://www.roblox.com/asset/?id=12997920786"

local animF = Instance.new("Animation")
animF.AnimationId = "http://www.roblox.com/asset/?id=12848925231"

local playAnimB = humanoid:LoadAnimation(animB)
local playAnimG = humanoid:LoadAnimation(animG)
local playAnimF = humanoid:LoadAnimation(animF)

local animPlaying = nil

game:GetService("UserInputService").InputBegan:connect(function(keyinput,chatting)
if chatting then
return
end
    	local key = string.lower(tostring(keyinput.KeyCode.Name))
	if key == "k" then
		-- Check if the player has a tool equipped or is seated, or if left ALT key is not being held down
		if player.Character:FindFirstChildWhichIsA("Tool") or humanoid.Sit or not UserInputService:IsKeyDown(Enum.KeyCode.LeftAlt) then
			return  -- Exit the function without playing the animation
		end

		if animPlaying == playAnimG then
			playAnimG:AdjustSpeed(1)
			playAnimG:Stop()
			animPlaying = nil
		else
			if animPlaying then
				animPlaying:AdjustSpeed(1)
				animPlaying:Stop()
			end
			playAnimG:Play()
			animPlaying = playAnimG
		end
	elseif key == "f" then
		-- Check if the player has a tool equipped or is seated, or if left ALT key is not being held down
		if player.Character:FindFirstChildWhichIsA("Tool") or humanoid.Sit or not UserInputService:IsKeyDown(Enum.KeyCode.LeftAlt) then
			return  -- Exit the function without playing the animation
		end

		if animPlaying == playAnimB then
			playAnimB:AdjustSpeed(1)
			playAnimB:Stop()
			animPlaying = nil
		else
			if animPlaying then
				animPlaying:AdjustSpeed(1)
				animPlaying:Stop()
			end
			playAnimB:Play()
			animPlaying = playAnimB
		end
	elseif key == "g" then
		-- Check if the player has a tool equipped or is seated, or if left ALT key is not being held down
		if player.Character:FindFirstChildWhichIsA("Tool") or humanoid.Sit or not UserInputService:IsKeyDown(Enum.KeyCode.LeftAlt) then
			return  -- Exit the function without playing the animation
		end

		if animPlaying == playAnimF then
			playAnimF:AdjustSpeed(1)
			playAnimF:Stop()
			animPlaying = nil
		else
			if animPlaying then
				animPlaying:AdjustSpeed(1)
				animPlaying:Stop()
			end
			playAnimF:Play()
			animPlaying = playAnimF
		end
	end
end)