Animation Not Playing In Game, but works in Studio

Not much else to say. The animation is working perfectly in studio, but isn’t working in the actual game people play.

(Btw, banging is an animation for a person banging on the floor.)


local player = game.Players.LocalPlayer
local character = player.Character 
local humanoid = character:FindFirstChild("Humanoid")
local Animator = humanoid:WaitForChild("Animator")
local ClickSpeed = 0 --if greater than 4.5 per second banging
local current = 0

local Banging = Instance.new("Animation")
Banging.AnimationId = "http://www.roblox.com/asset/?id=1234567890" -- I have actual id there irl, this is for example

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



local AnimationsTable = {
	["Begging"] = humanoid:LoadAnimation(Begging),
	["Banging"] = humanoid:LoadAnimation(Banging)
}

local CurrentStatusTable = {
	Begging = false,
	Banging = false,
	Standing = true,
	currentanimname = "Standing"
}

local function transition(To) --can be begging banging or standing
	
	if To == "Standing" then
		CurrentStatusTable.Banging = false
		CurrentStatusTable.Begging = false
		CurrentStatusTable.Standing = true
		for i,v in pairs(AnimationsTable) do
			if v.IsPlaying == true then
				v:Stop()
			end
		end
	end
	if To == "Banging" then
		CurrentStatusTable.Banging = true
		CurrentStatusTable.Begging = false
		CurrentStatusTable.Standing = false
		AnimationsTable.Banging.Looped = true
		print("banging animation playing")
		AnimationsTable.Banging:Play()
	end
	
	if To == "Begging" then
		CurrentStatusTable.Begging = true
		CurrentStatusTable.Banging = false
		CurrentStatusTable.Standing = false
		AnimationsTable.Begging.Looped = true
		print("begging animation playing")
		AnimationsTable.Begging:Play()
	end
	
	
end

local last = 0
RunService.Heartbeat:Connect(function()
	if os.time() - last > 2 then
		last = os.time()
		ClickSpeed = current
		current = 0
	
	
		if ClickSpeed == 0 and CurrentStatusTable.Standing == false then
			--transition to standing
			transition("Standing")
		end
		
		if ClickSpeed > 0 and ClickSpeed < 3 and CurrentStatusTable.Begging == false then
			--transition to begging
			transition("Begging")
		end
		if ClickSpeed > 3 and CurrentStatusTable.Banging == false then
			transition("Banging")
			
		end
		
	end
end)

Like I said, it works in studio but not in game. What’s wrong?

If the game is under a group you will need to have the animation uploaded to the group, otherwise It’ll only show up for you.

2 Likes

thank you for the help, I never knew that