How to play Idle animation on npc?

I am trying to make a script that plays an Idle animation on an npc, I do not own the animation and have not created it, I simply want the npc to play the animation, it’s the default idle animation for the animation called “Elder” and I can’t seem to get it to work, animation simply doesn’t play.

I have tried using roblox default Animate script and changing out the animation values to the “Elder” Idle animation values, I also made sure the script was server and not local. I have also tried the LoadAnimation function but that also did not work, maybe because I am not the owner / creator of the animation I am trying to play.

Any suggestions or ideas are strongly appreciated!

4 Likes

Make sure to do LoadAnimation into the Humanoid on an NPC. You could re-upload the Elder idle animation under your name by using animation editor > import animation then pasting the ID of the Elder idle animation in the bottom right corner. Maybe that will work.

1 Like

That’s totally false, you can play any animations that you want as long as you have his ID.

1 Like

It depend if your NPC is only going to not moving and non stop playing the Idle Animation or if he can move and play other animations.

If your NPC can move and do other things, like you was saying, you can copy the code from the default “Animate” local script of your character, then paste the code into a script in the NPC character, then change the animation ID inside it.
Just don’t forget, you also have to change some other things, as it was a local script, this was made for client side things, so you have to change the character to “script.Parent” for example.

If your NPC isn’t going to move, and just stay there playing the animation so you can do something like this (Code Below)
I made it in client side as it is just a visual “effect”, but i’m not sure if non player characters movements are also replicated into server side even while playing on client. If then, play it in server side through a script to avoid getting the animation being overplayed multiple times.
local script in StarterPlayerScript

--//Services//--
local WorkspaceService = game:GetService("Workspace")

--//Variables//--
local NPC = WorkspaceService:WaitForChild("NPC" ,300)
local Humanoid = NPC and NPC:WaitForChild("Humanoid" ,300)

--//Functions//--
local function PlayAnim()
	local NewAnim = Instance.new("Animation")
	NewAnim.AnimationId = "http://www.roblox.com/asset/?id=507770453"
	local Track = Humanoid:LoadAnimation(NewAnim)
	Track.Priority = Enum.AnimationPriority.Action4
	Track:Play()
	Track.Stopped:Connect(function()
		task.wait(1)
		Track:Play()
	end)
end

--//Connections//--
if NPC and Humanoid then
	PlayAnim()
end

Example there
NPC ANIM.rbxl (41,8 Ko)

5 Likes

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