How can i put an NPC playing a roblox emote (ex. Monkey Dance)

Hey everyone, hope you’re staying safe. I’m trying to make an NPC that plays the Monkey Dance. Though, I haven’t figured out how. I tried doing this, but couldn’t figure out how it works out.
Here’s the code I tried:

--Variables--
local set = script.Settings
local sp = set.Speed
local enabled = set.Enabled
local hum = script.Parent:WaitForChild("Humanoid")
if hum then
	print("Success")
else
	print("No Humanoid")
end
local humanim = game.InsertService:LoadAsset(3716636630).Parent

--Playing Animation--
if enabled.Value == true then
	humanim:Play()
	humanim.Looped = true
	humanim:AdjustSpeed(sp.Value)
end 

Any help is appreciated, also I am quite new to animation playing.

4 Likes

In order to play an animation you need to use :LoadAnimation()
Developer Reference

1 Like
local animationTrack = humanoid:LoadAnimation(animation)
animationTrack:Play()

and I am assuming I would put the emote ID into (animation)?

(animation) should be an animation instance.
For example:

local animation = script.Animation
animation.AnimationId = 912331
local animationTrack = humanoid:LoadAnimation(animation)
animationTrack:Play()

Ah, my question was how can I play an emote as in an NPC. An emote being for example the Monkey Dance or the Twirl

I understand that. You’d create an animation instance, with the animation ID being the emote you are attempting to play. The above script would work for this.

local animation = script.Animation
animation.AnimationId = 3716636630
local animationTrack = humanoid:LoadAnimation(animation)
animationTrack:Play()

I tried that, though humanoid is underlined with a yellow line. I tried replacing it with “hum” though it did not work.

You need to specify the humanoid of the NPC.

--Variables--
local set = script.Settings
local sp = set.Speed
local enabled = set.Enabled
local humanoid = script.Parent:WaitForChild("Humanoid")

--Playing Animation--
local animation = script.Animation
animation.AnimationId = 3716636630
local animationTrack = humanoid:LoadAnimation(animation)
animationTrack:Play()

This is the code, and it did not play the animation. Have I specified the humanoid incorrectly?

Your ID isn’t right. You probably copied the id from the url in the catalog? Well for some reason roblox decided to put another ID there (That’s the ID of the emote I think, not the animation). But basically I use the chrome extension BTRoblox which lets me see the animation that is “hidden” behind the emote. This is the ID of the “Monkey” animation: 3333499508.

After you install the extension and go to an emote in the catalog you should see something like this:
image

You need to click it and then you can see the animation behind the emote and it’s ID:

image

2 Likes

Wow, that is very useful. Thank you for your assistance.

1 Like