Animation works in studio but not in-game

I have 2 animations for a simulator one is for “eat” the other is “attack” they both play when the player clicks on the ui and then clicks on the screen, just as other simulators.

For some reason, both animations work fine in studio testing but in-game the attack animation works but the eat animation does not. Both animations are published under the same group, both should be working just fine

We have tried re-publishing the animation and that hasn’t worked. It can’t be anything with the animation script otherwise both anims wouldn’t be working.

If y’all need me to show anything please just ask, im honestly not sure what is causing the problem so have no idea what to show.

2 Likes

Are the animations set to action mode?
If not, make sure they are.

What you can do is actually dupe the animation script and put it in starter character scripts and you can manipulate all the animations there.

Yes the priority is set to action. We have the animationhandler in starterplayerscripts as well.

I dont know then. Must be some sort of internal error.

Can you show the code that plays these animations?

Perhaps you are using a deprecated method, and sometimes deprecated methods only function in studio (not all the time).

Are you using,
:LoadAnimation() or animator or humanoid:

1 Like

sorry for the late reply, this is the animationhandler script

local Player = game.Players.LocalPlayer
local AnimationHandler = {}

local Ids = {
	["Eat"] = "rbxassetid://8782945776",
	["Attack1"] = "rbxassetid://8780852058",
	["Attack2"] = "rbxassetid://8780852058",
	["Attack3"] = "rbxassetid://8780852058",
}

local LoadedAnims = {}

function AnimationHandler.PreLoad(Character)
	local Hum = Character:WaitForChild("Humanoid")
	
	for Name,Id in pairs(Ids) do
		local AnimObj = Instance.new("Animation")
		AnimObj.AnimationId = Id
		local Anim = Hum:LoadAnimation(AnimObj)
		Anim.Priority = "Action"
		
		LoadedAnims[Name] = Anim
	end
end

function AnimationHandler.PlayAnimation(Name)
	if LoadedAnims[tostring(Name)] ~= nil then
		LoadedAnims[tostring(Name)]:Play()
	end
end

Player.CharacterAdded:Connect(function(Character)
	AnimationHandler.PreLoad(Character)
end)

AnimationHandler.PreLoad(Player.Character or Player.CharacterAdded:Wait())
return AnimationHandler

You are using LoadAnimation, which has been depracted (hence @TheZanderius reply)

You need to use Animator to load animations instead of LoadAnimation