Duplicating player animations to an "NPC"

While it technically isn’t an “NPC”, the basic gist of it is that I’m attempting to find the player’s current animations and then duplicate these onto a duplication of said player, which will function as an NPC. I’m able to duplicate the player and all fine, however I’m seemingly unable to duplicate the animations. I’ve read into the wiki and doing Humanoid:GetPlayingAnimationTracks() would output a table value of all the animation tracks playing. I use a pairs loop in order to go through each of the animation tracks, getting their animations and then running those animations onto the NPC’s character. While there are no visible errors in the output, it doesn’t seem to have any effect. I’ve also tried using an animation controller, duplicating the animation track’s animation Id to the controller and then playing that under the NPC’s model. Both have no visible effect. Am I unable to use an animation track’s animation ID as it’s a “Read-only” value? Here’s my code, if there’s any errors, feel free to enlighten me! :wink: (Just to be clear, I’m running this from a server-side script within the player’s character model)

for i, track in pairs(Character.Humanoid:GetPlayingAnimationTracks()) do
    --[[local animControllor = Instance.new("AnimationController", AfterImage)
    local t =animControllor:LoadAnimation(track.Animation)
    t:Play()--]]
    AfterImage.Humanoid:LoadAnimation(track.Animation)
end

The commented code was used for animation controller, whereas the current code uses it directly into the Humanoid.

1 Like

According to the GetPlayingAnimationTracks page, it only returns tracks that are playing, so those that are only loaded will not be returned. However, I think there’s usually a folder under each player’s humanoid called “Animations”. Not sure though, so I’d just go in Play Solo and look around your character. Once you find the folder I’m talking about, wherever it may be, you can probably figure out what to do.

I think I phrased my post a bit badly - I wanted to copy the currently playing animations from the player’s humanoid, though thanks for the reply, I’ll look into it.

1 Like

The humanoid doesn’t have anything that changes when animations played are changed. The same goes for the animate script’s children.

I would use run service .renderStepped and find the part offset from humanoid root part of the player and duplicate the effect on the NPC.

2 Likes

That seems plausible and I can see how would one would implement that into said game. Thanks for the help. :slight_smile: