Can you load one animation on multiple humanoids?

I have 2 quick questions about animations.

  1. Can you load one animation on multiple humanoids? (animator:LoadAnimation()) also this is on the server. I know you can on the client.

  2. How do animations clean up? If I make a new animation and load it then play the track but I lose reference to it will it clean up or do I have to destroy it.

Thanks in advance for any help!

I don’t know much about animations but can’t you just loop through all the humanoids and then load the animation for each humanoid?

local Characters = ...:GetChildren() --assuming characters are in a group

for _, character in pairs(Characters) do
    local Humanoid = character:WaitForChild("Humanoid")
    Humanoid:LoadAnimation()
end
1 Like

Yea I’m not having an issue with finding a way to load them. I’m wonder if you could use one animation instance on multiple humanoids. Example:

local anim = Instance.new(“Animation”)

local Track1 = humanoid1:LoadAnimation(anim)
local Track2 = humanoid2:LoadAnimation(anim)

(this isn’t actually how I’m going to code it but works as an example.)

It is indeed possible.


You can see that both noobs play the same idle animation, and I have loaded both of them with the same server script.

1 Like

Yes.

local Chars = {Character1, Character2} or ...:GetChildren() -- Table containing Characters, or you can set this variable to getting the children of an instance, choose one of these depending on what you're trying to accomplish

for _,character in Chars do
local humanoid = character.Humanoid
local track = humanoid:LoadAnimation(animationInstance) --replace animationInstance with your animation 
track:Play()
end
1 Like

Yes, you can do this. The animation is just a template to make an AnimationTrack. If you want the same AnimationTrack to control two humanoids, you can’t do that.

2 Likes

Also, you can use game:GetService("Debris") to delete the animation over time, or you can animationTrack.Ended

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.