Can't make NPC do an emote

I’m trying to make an NPC do the Baby Dance emote that everyone can see.

I’ve made a script that inserts an animation, loads it into the Humanoid, and plays the emote. This doesn’t work, and no errors appear in the output.

I’ve tried looking at the Developer Forum and Scripting Helpers but haven’t really found anything useful or that worked for what I’m trying to do.

My script is inside the NPC’s humanoid.

local USERID = script:WaitForChild("TOPDONORUSERID").Value
local humanoidDescriptionForUser = game.Players:GetHumanoidDescriptionFromUserId(USERID)
local Humanoid = script.Parent
local Players = game:GetService("Players")

Humanoid:ApplyDescription(humanoidDescriptionForUser)
local humanoidDescription = Humanoid.HumanoidDescription
local Humanoid = script.Parent

local name = Players:GetNameFromUserIdAsync(USERID)
Humanoid.DisplayName = name

local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://4272484885"

local animtrack = Humanoid:LoadAnimation(anim)

animtrack.Looped = true
animtrack.Priority = Enum.AnimationPriority.Action
animtrack:Play()

Does anyone know how to fix this, It’s really annoying and I can’t find anything to solve it.

2 Likes

Maybe try changing the animation ID to “rbxassetid://AnimationId” instead.

Edit: AnimationId is where your id should go btw.

make sure the npc is unanchored, your animations priority is action. nothing is wrong with that script except maybe the humanoid description part.

1 Like

Make sure you the NPC isn’t anchored and you’re using the right… animations I guess? (R6/R15)

2 Likes

@LukeWasAlreadyTaken changing the animation ID using rbxassetid:// didnt change anything
@ekuz0diaa i’ve tried it both anchored and unanchored, nothing. setting the priority changed nothing
@CalebbXVI i’ve tried it both with and without being anchored to no avail, the NPC is R15.

i’ve updated the code on my post

Perhaps try changing the animation priority inside the animation editor?

Edit: As well as the looped statement

Wait…why not fire a remoteevent so when the server starts the animation plays?

Perhaps try changing the animation priority inside the animation editor?

it’s not my animation, it’s an emote.

Wait…why not fire a remoteevent so when the server starts the animation plays?

there’s no need, this is already being fired on the server.

local name = Players:GetNameFromUserIdAsync(USERID)
Humanoid.DisplayName = name

Where is the UserId?

the userid is from an IntValue inside the script.

local USERID = script:WaitForChild("TOPDONORUSERID").Value

Right here. If you look closely, you can clearly see local USERID = script:WaitForChild("TOPDONORUSERID").Value.

Perhaps trying to remove the looped statement and the priority statement because if you have an emote and you play for example the hype dance, it will already be looped and probably priority high

Right, I didn’t notice. i can’t seem the to find the problem with the script.

Nothing (30 charrrssssssssssss)

Eh, I’m kinda late on this but I guess I found the solution. Since the animation is from roblox, I’m not really sure if you could play it but here’s what I did:

1 - Download the animation file, paste this in your browser: http://www.roblox.com/Asset?ID=EMOTEID. It’ll download a file, rename it using “.rbxm” at the end of it.

2 - Import the animation to your roblox studio, then you may use one script to play it, this one is the looped version:

local Animation = script:WaitForChild("Fashionable")
local Humanoid = script.Parent:WaitForChild("Humanoid")
local AnimTrack = nil

if Humanoid ~= nil then
	AnimTrack = Humanoid:LoadAnimation(Animation)
	print("Animation loaded on NPC (" .. script.Parent.Name .. "). Animation = " .. Animation.Name .. ".")
else
	print("Cannot load animation " .. Animation.Name .. " because the current Humanoid is nil. NPC = " .. script.Parent.Name .. ".")
	return
end

spawn(function()
	while wait() do
		if Humanoid ~= nil and AnimTrack ~= nil and not AnimTrack.IsPlaying then
			AnimTrack:Play()
		end
	end
end)

I hope it works, let me know if it doesn’t.

1 Like