Animation playing in studio, not in-game; the animation is under my group

Hey everybody… I’ve had this problem now for a day and no matter what I do or think up of I can’t figure out why this won’t work properly…

  1. What do you want to achieve? I simply want an idle animation to play once a player equips a weapon (currently only one weapon named “Fists”).

  2. What is the issue? Whenever I equip the weapon while playtesting in studio, the idle animation will play perfectly fine. However, after publishing and going into the game from Roblox, no idle animation will play when I equip my “Fists” weapon. No errors are displayed in the developer log in either studio or Roblox.

Here’s a short video of the animation playing properly in studio (you can tell it’s studio cause I didn’t crop it well):

And here’s a clip of me going into the game not on studio:

  1. What solutions have you tried so far? I have checked the scripts that I use for animations, both on the server and client sides. I’m always sure to have the most recent version of the game published when trying to test if I fix the bug in the actual game. My animations are uploaded onto my group which the game that I’m working on is also under. I’ve set the priority for my animation to “Idle” and have also re-uploaded it in a hopeless attempt of trying to fix this… (As far as I know, I haven’t seen anybody have a similar problem, it’s just forgetting to upload the animation to the proper place…)

Here’s the code that I use on the client side (forgive me if it’s any bit hard to read):

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local eventFolder = ReplicatedStorage:WaitForChild("Events")
local animEntityEvent = eventFolder:WaitForChild("AnimateEntity")

local function setAnimation(entity, animFolder, animName)
	local humanoid = entity:WaitForChild("Humanoid")

	if humanoid and animFolder then
		local animation = animFolder:FindFirstChild(animName)
		if animation ~= nil then
			local animator = humanoid:FindFirstChild("Animator") or Instance.new("Animator", humanoid)
			
			local playingTracks = 	animator:GetPlayingAnimationTracks()
			for i, track in ipairs(playingTracks) do
				if track.Name == animName then
					return track
				end
			end
			local animationTrack = animator:LoadAnimation(animation)
			return animationTrack
		end
	else
		warn("animation for "..entity.." broke!")
		return false
	end
end

local function stopAnimation(entity, animName)
	local humanoid = entity:WaitForChild("Humanoid")
	
	if humanoid then
		local animator = humanoid:FindFirstChild("Animator") or Instance.new("Animator", humanoid)
		local playingTracks = 	animator:GetPlayingAnimationTracks()
		for i, track in ipairs(playingTracks) do
			if track.Name == animName then
				track:Stop()
			end
		end
	else
		warn("error stopping animation for "..entity.."!")
	end
end

local function playAnim(entity, animFolder, animName)
	local animTrack = false
	
	if animFolder[animName]:IsA("Folder") then
		animFolder = animFolder[animName]
		animName = "main"..math.random(1, #animFolder:GetChildren())
		animTrack = setAnimation(entity, animFolder, animName)
	else
		animTrack = setAnimation(entity, animFolder, animName)
	end
	
	if animTrack ~= false then
		animTrack:Play()
	else
		warn("animation broke lol")
	end
end

game.Workspace.Enemies.ChildAdded:Connect(function(entity)
	if entity:IsA("Model") then
		local animFolder = entity:FindFirstChild("Animations")
		if animFolder then
			playAnim(entity, animFolder, "move", true)
		else
			warn("no animations folder found for entity "..entity.Name)
		end
	end
end)

animEntityEvent.OnClientEvent:Connect(function(entity, animFolder, name, playOrStop)
	if playOrStop == true then
		--play animation
		playAnim(entity, animFolder, name)
		print(name)
	elseif playOrStop == false then
		--stop animation
		stopAnimation(entity, name)
	else
		--invalid value
		warn("invalid value given to player, check value being passed: "..playOrStop)
	end
end)

The weird thing about all this is, if replace the animation with the default walking or idle animation, it will play perfectly fine in studio and in-game. Using my scripts apparently don’t work for some reason?

I hope I’m not missing something painfully obvious, but I really can’t tell why this happens.

thanks in advance for any help…

1 Like

Try setting the Animations’ AnimationId to “http://www.roblox.com/asset/?id=YOUR_ID

Have you verified that it’s not an issue relating to animation priority?

Not entirely, but I am very sure it isn’t the issue. I did end up replacing the idle animation that doesn’t appear in-game with the walking animation by editing the “Aniamte” local script that player characters get when joining a game. The animation showed when I walked in studio and in-game, so I kinda doubt it would have to do with animation priority.

Then again, I’ve ran out of ideas as to where the issue is coming from, so I don’t entirely deny that it might be animation priority, I just think it might be something else…

Not sure if I’m understanding correctly…

The system that I’m trying to use has each weapon have a bunch of animations stored in a Configuration folder parents to the weapon itself.

Assuming you’re referring to the animation being stored there, I do have the animation set to the published animation’s ID.

Here are a few pictures:

What’s inside the “Fists” tool:
Screen Shot 2022-08-17 at 10.48.50 AM

Properties for the “idle” Animation for the Fists tool/weapon.

Try changing rbxassetid:// to what I sent you above.

My bad! I understand what you mean now.

Unfortunately nothing seems to have changed, the animation still will only play in studio, not in-game. It was worth a shot though…

In-game (I have Fists equipped, and no arms on-screen…):

Check your character in third-person (enable it for testing) and see if the animation plays, if not, is the Animation priority set to Action or higher?

I set it so that the player’s camera is no longer on LockFirstPerson, published, and joined the game, but it still shows no animation…

I even tried overwriting the animation to be set to “Action” for its priority instead of Idle… nothing changed…

The code on the client side also now prints the name of the animation after it does :Play() on the loaded animation track. Here are the results that I get from studio and in-game after equipping fists

Studio:
Screen Shot 2022-08-17 at 1.45.26 PM

Game (the "attack"s are just from me clicking my mouse):

Maybe I should just re-write my script on the client side? The animation can play in-game, but using the script I have right now, it seems to just not want to…

Finally got it figured out and working…

Turns out that having the name of the animation stored in the Animations folder as “idle” will just not work. I do not know why this happens, but after I changed the name to what it currently is, “weaponIdle”, the animation will play both in studio and in-game!

I would really like to know why this actually happens, but I’m sick of this problem so I’m just sticking with not naming any of my animations “idle” now…

But yeah, apparently “idle” is not a good name for animations…

1 Like