Drinking animation works in studio test mode, but not in-game

I want to achieve a drinking animation that plays whenever you click with the tool equipped. The issue is that the animation and local script work completely fine when tested in studio, however, do not work when used in-game. I have tried some solutions like using different scripts, however, this gave me the best results.

local player =  game:GetService("Players").LocalPlayer
local character =  player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animator =  humanoid:WaitForChild("Animator")
local anim = script.Parent.DrinkAnim
local track = animator:LoadAnimation(anim)
local isFinished = true
local sound =  script.Parent.DrinkSound
local isEquipped = false
local tool = script.Parent


tool.Activated:Connect(function(playAnim)
	if isFinished == true and isEquipped == true then
		isFinished = false
		track:Play()
		wait(track.Length/4)
		sound:Play()
		track.Stopped:Wait()
		isFinished = true
	end	
end)


tool.Equipped:Connect(function()
	isEquipped = true
end)
	
tool.Unequipped:Connect(function()
		isEquipped = false		
end)
local mug = script.Parent
local isEquipped = false
local isFinished = true

mug.Equipped:Connect(function(Mouse)
	local animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.DrinkAnim)
	local sound =  script.Parent.DrinkSound
	local isEquipped = true
	Mouse.Button1Down:Connect(function()
		if isEquipped and isFinished then
			isFinished = false
			animation:Play()
			wait(animation.Length/4)
			sound:Play()
			wait((animation.Length)*(3/4))
			isFinished = true
		end
	end)
end)

mug.Unequipped:Connect(function()
	isEquipped = false
end)

Screenshot 2023-06-14 at 01.37.58

Edit: It randomly started working overnight even though I did not change anything, I guess Roblox may have had some issues.

Animations that you own under your account cannot be played in group games, same goes to the opposite.

Nope, does not seem to work. The animation is placed under the group.