Food animation script works in studio, but not In-game | NEED HELP

I made an animation for a food item and It worked perfectly in studio, however it doesn’t work in studio. This is the script (its server-side):

local tool = script.Parent
local animation = script.Parent.EatingAnimation

tool.Equipped:Connect(function()
	tool.Activated:Connect(function()
		local Character = tool.Parent
		local AnimationTrack = Character.Humanoid:LoadAnimation(animation)
		AnimationTrack:Play()
	end)
end)
1 Like

Make it a local script, not a server script.

1 Like

Put that in local script

   local tool = script.Parent
    local animation = script.Parent.EatingAnimation

    tool.Equipped:Connect(function()
    	tool.Activated:Connect(function()
    		local Character = game.Players.LocalPlayer.Character -- or you can try game.workspce[game.Players.LocalPlayer.Name].Humanoid
    		local AnimationTrack = Character.Humanoid:LoadAnimation(animation)
    		AnimationTrack:Play()
    	end)
    end)
1 Like

Still not working, something is up with line 2

local animation = script.Parent.EatingAnimation

Can you screen shot me that animation?

1 Like

i gtg i will tomorrow be back later.

You can see my script.

Ignore _G thing

Try adding a animator to the character Humanoid

Normal Script in ServerScriptStorage

game.Players.PlayerAdded:Connect(function(player)
      player.CharacterAdded:Connect(function(character)
            local Humanoid = character:WaitForChild("Humanoid")
            local Animator = Instance.new("Animator")
            Animator.Parent = Humanoid
      end)
end)

the in your other script load animation through animator

local Animator = Humanoid:FindFirstChild("Animator")

--other code here

Animator:LoadAnimation(Anim)

If it works in-studio but not in game, your animation might not of uploaded correctly. If the game is a group game, you need to make sure the animation belongs to the group.

Hope I could help!

1 Like

Oh okay that actually helps a lot. I had it under my name instead xd