Animation works in studio but not ingame

Let’s start off with the problem. I have towers for a tower defense game (like it should) and I have added animations to them. They seem to work perfectly fine in studio when I test it but if I join the actual game, they don’t load.

Video

Script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local events = ReplicatedStorage:WaitForChild("events")
local tower_animate = events:WaitForChild("tower_animate")

local function set_anim(object, animName)
	local humanoid = object:WaitForChild("Humanoid")
	local anim_folder = object:WaitForChild("Animations")
	
	if humanoid and anim_folder then
		local anim_object = anim_folder:WaitForChild(animName)
		
		if anim_object then
			local animator = humanoid:FindFirstChild("Animator") or Instance.new("Animator", humanoid)
			
			local playing_tracks = animator:GetPlayingAnimationTracks()
			for i,track in pairs(playing_tracks) do
				if track.Name == animName then
					return track
				end
			end
			local anim_track = animator:LoadAnimation(anim_object)
			return anim_track
		end
	end
end

local function play_anim(object, animName)
	local anim_track = set_anim(object, animName)
	if anim_track then
		anim_track:Play()
	else
		warn("Anim unavailable")
		return
	end
end

workspace.placed_towers.ChildAdded:Connect(function(object)
	play_anim(object, "Idle")
end)

tower_animate.OnClientEvent:Connect(function(tower, anim_name)
	play_anim(tower, anim_name)
end)

Yes, the anims are published in a group.
There are no errors shown in the output.

There are two reasons as to why I think this is happening. Is the game owner the Group or you? If it’s you as the owner then reupload the animations into your account. Second reason is that it’s a local script, maybe changing it to a server script? If these are the cases then I am not too sure.

1 Like

Is it producing any errors? Found by pressing F9, check the local and server-side outputs.

Yes, this is very likely his case.
I sometimes forget to publish some animations in the group that owns the game I’m making and just realize when I call people to test with me and then I see that the animations won’t load lol.

Like I said below the script:

(extra chars)

The game owner is my group and I published the anims under the group

you have to publish it first, its just how the thing works idk why

I had the exact same issue with you before. I solved it by publishing the game.

The game is published though???