Player's Idle Animation on NPC Won't Play

Hey! I have a script that creates an NPC version of a player and I am wondering how I can load their idle animation onto the NPC. I know how to get the player’s idle, but not how to use it.

I have tried several attempts, and using an animation that I own (as in uploaded myself to Roblox) it works, but Roblox’s animations don’t. I also tried the whole copy the “Animation” localscript and then change it to script method but that only plays the default idle - not the player’s idle. I also tried downloading an Idle animation that Roblox made which gave me a group with multiple animations and using one of those worked - but it’s not the full Idle nor do I know how to get that from the full Idle animation ID.

Any ideas on how to get this to work?

1 Like

You could use Humanoid Description

Take a look at this article and see if it answers any of your questions:

That’s what I use to get the animation but it doesn’t work. I am pretty sure it gives me the pack not the actual animation?

Well I have a few things to say.

When you were initially scripting the animation to play on the humanoid, not using the players animate script copy and paste. Was it inside a server or local script?

You can use Animation Controller to play the animations you want onto the NPC.

You can make a server script inside the NPC and manually play the idle animation like this

local animation = script:WaitForChild('Animation')
local humanoid = script.Parent:WaitForChild('Humanoid')
local idle = humanoid:LoadAnimation(animation)

A side note, you can’t animate an NPC using a local script. So the reason why the copy and paste for the animate script wouldn’t work was because local script run only if it’s a descendant of a player instance I think.

So you can

  • Copy and paste the animation script inside the NPC
  • Copy the script using Ctrl + A
  • Insert a server script inside the NPC
  • Paste the script inside the server script and do the following

On lines 714- 752 paste this.

-- setup emote chat hook
	local emote = ""
	if (string.sub(msg, 1, 3) == "/e ") then
		emote = string.sub(msg, 4)
	elseif (string.sub(msg, 1, 7) == "/emote ") then
		emote = string.sub(msg, 8)
	if (pose == "Standing" and emoteNames[emote] ~= nil) then
		playAnimation(emote, EMOTE_TRANSITION_TIME, Humanoid)

-- emote bindable hook
if FFlagAnimateScriptEmoteHook then
	script:WaitForChild("PlayEmote").OnInvoke = function(emote)
		-- Only play emotes when idling
		if pose ~= "Standing" then
		if emoteNames[emote] ~= nil then
			-- Default emotes
			playAnimation(emote, EMOTE_TRANSITION_TIME, Humanoid)
			return true
		elseif typeof(emote) == "Instance" and emote:IsA("Animation") then
			-- Non-default emotes
			playEmote(emote, EMOTE_TRANSITION_TIME, Humanoid)
			return true
		-- Return false to indicate that the emote could not be played
		return false

The id contained in HumanoidDescription.IdleAnimation isn’t an actual animation id which is why this wasn’t working. It returns an id that would bring you to as an example; So I used InsertService to insert it and then grab the actual animation. Which looked like the following:

   local model = game:GetService("InsertService"):LoadAsset(humanoid.HumanoidDescription.IdleAnimation)
   local animation = model.R15Anim.idle.Animation2
   local animationTrack = humanoid:LoadAnimation(animation)
   animationTrack.Looped = true

Which ended up working, thanks for the help!