Why does my friend's animation show only for him?

Hi!, I’m trying to make a Tower Defense Game, But I ran into an Issue. The issue is that my friend’s animation shows only for him(in Roblox Studio). And in Roblox the animation doesn’t show to anybody. I want to fix it, but I don’t how. The only solution I’ve tried so far is to search on YouTube.

Do you know what cause this. The script or the animation?

Here is the part in the local script that plays the animation:

local animateTowerEvent = game.ReplicatedStorage:WaitForChild("Events").AnimateTower

local function setAnimations(object, animName)
	local humanoid = object:WaitForChild("Humanoid")
	local animFolder = object:WaitForChild("Animations")
	
	if animFolder and humanoid then
		local animationObject = animFolder:WaitForChild(animName)
		
		if animationObject then
			local animator = humanoid:WaitForChild("Animator")
			
			local animTrack = animator:LoadAnimation(animationObject)
			return animTrack
		end
	end
end

local function playAnimation(object, animName)
	local animationTrack = setAnimations(object, animName)
	
	if animationTrack then
		animationTrack:Play()
	else
		warn("Animation track doesn't exists")
		return
	end
end

workspace.Towers.ChildAdded:Connect(function(object)
	playAnimation(object, "Idle")
end)

workspace.Mobs.ChildAdded:Connect(function(object)
	playAnimation(object, "Walk")
end)

animateTowerEvent.OnClientEvent:Connect(function(tower, animName)
	playAnimation(tower, animName)
end)

The local script is inside StarterPlayerScripts.

2 Likes

Maybe it hasn’t been approved by moderation yet?

I’ve been waiting a day is that enough time?

See the “Should I load an Animation on the client or server?” section on the following page: Animator:LoadAnimation()

I can’t tell for sure based on the code/context you’ve provided, but my guess would be that since the models you’re attempting to load these animations on are not a descendant of a player’s Character, they are not replicated to other clients.

Unfortunately it’s still not working.

It would be easier for me to help you if you explained what you tried after reading my post.

I tried to load the animation from the server.

Alright, so you’re using a Script (not a LocalScript)? Any errors or warnings in the Output? Are you calling LoadAnimation() on a Humanoid or AnimationController? Are the models you’re attempting to animate created on the server or on the client? Could I see the code you currently have for loading and playing animations?

I’m using Script, No errors, Animator I don’t know what’s AnimationController, server, Script:

local function playAnimationFromServer(character, animationName)
	local humanoid = character:FindFirstChildOfClass("Humanoid")
	if humanoid then
		
		local animator = humanoid:FindFirstChildOfClass("Animator")
		if animator then
			local animationTrack = animator:LoadAnimation(character:WaitForChild(animationName))
			animationTrack:Play()
			return animationTrack
		end
	end
end

workspace.Towers.ChildAdded:Connect(function(object)
	playAnimationFromServer(object, "Idle")
end)

workspace.Mobs.ChildAdded:Connect(function(object)
	playAnimationFromServer(object, "Walk")
end)

Try adding a print statement after the line that reads if animator then. I have a feeling this code never get’s ran because the Animator is created only once :LoadAnimation() is called on a Humanoid or AnimationController. To be clear, the code snippet you just sent should now look like this:

local function playAnimationFromServer(character, animationName)
	local humanoid = character:FindFirstChildOfClass("Humanoid")
	if humanoid then
		
		local animator = humanoid:FindFirstChildOfClass("Animator")
		if animator then
			print("FOUND")
			local animationTrack = animator:LoadAnimation(character:WaitForChild(animationName))
			animationTrack:Play()
			return animationTrack
		else
			print("NOT FOUND")
		end
	end
end

workspace.Towers.ChildAdded:Connect(function(object)
	playAnimationFromServer(object, "Idle")
end)

workspace.Mobs.ChildAdded:Connect(function(object)
	playAnimationFromServer(object, "Walk")
end)

Let me know what you see in Output after running this

It printed Found once is that good?

There are two animations Idle animation and walking animation

walking animation priority set to Movement
idle animation priority set to Idle

From what I know, animations only work on who currently owns the animation asset in studio playtest

But in Roblox playtest it doesn’t show to anybody

Huh that’s actually odd. Is the newest update public (most likely suggest doing it in a test place for nothing to break)

If not, look in developer console in game for any errors. if you own the place, you will be able to see client sided script errors (which everyone can see), and server sided script errors (which only developers of the game can see)

There are no errors, i don’t know why its not working

Send the place file. I’ll figure out what’s not working

Can you tell me how because it’s gonna my first time

Nevermind i know how to so don’t tell me

PleaseFix.rbxl (133.8 KB)