Animations not being visible to other players through local scripts

Hello, so I have a set of animations that are played through by various local scripts (ex. a tool, running animation, etc.) and I was wondering about why they weren’t being shown through other players.

I also additionally used a custom character (it’s just the same avatar but with a mushroom head)

I have tried doing many methods to solve this problem like creating the animations INSIDE of the character instead of just being made by the local script but the local script loads the animation (animationTrack) but it still hasn’t worked for some reason.

I think it’s quite strange why it doesn’t play the animation even though animations are global to everyone. If you would like a script, here are two scripts that I have used some of the animations on.

script 1 (the animation giver):

local Scrooms = game.ReplicatedStorage.ScroomRandomizer

game.Players.CharacterAutoLoads = false

game.Players.PlayerAdded:Connect(function(player)
	local ScroomsFolder = Scrooms:GetChildren()
	local ChosenScroom = ScroomsFolder[math.random(1,#ScroomsFolder)]
	
	local character = ChosenScroom:Clone()
	character.Name = player.Name
	player.Character = character
	character.Parent = workspace
	
	
	
	local ScroomDecomposeDown = Instance.new("Animation")
	ScroomDecomposeDown.Parent = character
	ScroomDecomposeDown.Name = "ScroomDecomposeDown"
	ScroomDecomposeDown.AnimationId = "rbxassetid://5700277977"
	
	local ScroomDecomposeUp = Instance.new("Animation")
	ScroomDecomposeUp.Parent = character
	ScroomDecomposeUp.Name = "ScroomDecomposeUp"
	ScroomDecomposeUp.AnimationId = "rbxassetid://5700288886"
	
	local RunAnimation = Instance.new("Animation")
	RunAnimation.Parent = character
	RunAnimation.AnimationId = "rbxassetid://5703067458"
	RunAnimation.Name = "RunAnimation"
	
	local MineAnimation = Instance.new("Animation")
	MineAnimation.Parent = character
	MineAnimation.AnimationId = "rbxassetid://5702911825"
	MineAnimation.Name = "MineAnimation"
end)

script 2 (a tool animation):

local tool = script.Parent

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

local humanoid = character:WaitForChild("Humanoid")

local MineAnimation = character:WaitForChild("MineAnimation")

local animationTrack = humanoid:LoadAnimation(MineAnimation)

tool.Activated:Connect(function()
	if not animationTrack.IsPlaying then
		local AnimationTracks = humanoid:GetPlayingAnimationTracks()
		
		animationTrack:Play()
	end
end)
2 Likes

you have to play the animation through a script, local scripts only work for that one player. For others to see it make it server side

1 Like

I always thought that even if you play it through a local script, the animation will be still be global and visible to other players?

1 Like

is the animation a action? It seems that my code runs in a local script as an action.

1 Like

They won’t, due to LocalScripts only running for the client rather for the server. You’d probably want to use RemoteEvent to notify the server, then play the animation on that player.

3 Likes

Uh, alright then. I’ll test that out.

2 Likes

yes like I said earlier but in one of my codes the animation does play in a local script and is shown to every one. Though I think his animation is a core then action. Or since its running and stuff make the animation under movement

1 Like

If action doesn’t work try the option movement

1 Like

Hm, I thought those only set animation priority.

1 Like

yes what I mean with action is the animation priority

1 Like

what do you mean those only set?

1 Like

Like they set animation priority. Say if you played two animations at once with one set to Action and the other set to Core. The one set to Action would take priority and play

1 Like

uh so like animations CAN be played through a local script

2 Likes

Also if non of those work, instead of placing new animations in player just add animations to the local script like this: Example code:

local anim = script.Parent.Animation

local loadAnim = player.Character.Humanoid:LoadAnimation(anim)
loadAnim:Play()

1 Like

yes local scripts do work, well for me at least

1 Like

ok i’m just going to put the animations in the character manually and see if that works

1 Like

Hi, I had a very similar problem to this and i was confused as heck, but it turns out if you load your own characters, you also have to handle some other stuff, like building an animator.

Here’s what we run for loading a custom character, and it works with a local animation script:

function CharacterLoader:LoadNewCharacterAtLocation(CharacterModel,newVector)
    print("Loading character for " .. self.Player.Name)
    local character = CharacterModel:Clone()
    character.Name = self.Player.Name
    self:DestroyCharacter()
    self.Player.Character = character
    local Animator = Instance.new("Animator")
    Animator.Parent = character.Humanoid
    character.Parent = workspace
    character.PrimaryPart:SetNetworkOwner(self.Player)
    character.PrimaryPart.CFrame = CFrame.new(newVector)
end

As you can see, we also create an Animator, and set some network ownership. I don’t know if it’s necessary to set network ownership or not, but I do it because it’s a logical step in the process of creating a custom character.

4 Likes

Wow, parts from this function actually worked!

Thank you all for helping, very much appreciated!

4 Likes

This is actually incorrect; animations that are played within the humanoid are replicated to all clients and not only the current player. The issue to this is more than likely because the humanoid doesn’t have an Animator. But I am pretty certain :LoadAnimation() creates an Animator automatically if there already isn’t one, which is quite unusual.

Hey I had the same problem and I just used a RemoteEvent to run it on the server but it wasn’t showing on the client-side so I did the same.
Soo it looks like this for my personal code

Serverside

game.ReplicatedStorage.Animations.Animate.OnServerEvent:Connect(function(plr)
	local Humanoid = plr.Character.Humanoid
	local Anims = game.ReplicatedStorage.Animations
	local PortArmsTrack =  Humanoid:LoadAnimation(Anims.PortArms)
	local AimingTrack = Humanoid:LoadAnimation(Anims.Aiming)
	PortArmsTrack.Priority = Enum.AnimationPriority.Action
	AimingTrack.Priority = Enum.AnimationPriority.Action
	PortArmsTrack:Play()
end)
Client Side
local player = game.Players.LocalPlayer
local Event 
script.Parent.Equipped:Connect(function()
	local Anims = game.ReplicatedStorage.Animations
	
	local char = player.Character or player.CharacterAdded:Wait()
	local Humanoid = char:WaitForChild('Humanoid')
	
	Anims.Animate:FireServer()
	
	local PortArmsTrack =  Humanoid:LoadAnimation(Anims.PortArms)
	local AimingTrack = Humanoid:LoadAnimation(Anims.Aiming)
	PortArmsTrack.Priority = Enum.AnimationPriority.Action
	AimingTrack.Priority = Enum.AnimationPriority.Action
	PortArmsTrack:Play()

end)