How to make custom emote command

  1. What do you want to achieve?
    I want to create my own emotes that are playable by using /e command.
    I currently have made one emote called “rat”, which is just the Rat Dance meme.

  2. What is the issue?
    The problem is that, instead of playing the emote, I instead get this error message in chat:
    image

  3. What solutions have you tried so far?
    I tried looking for solutions on the Forums, but none of the found Posts helped.
    Edit: Forgot to mention that I tried setting UserEmotesEnabled to false and this is the error message I got instead:
    image

I also tried adding prints in each function to see if they were even fired and they weren’t.
I’m genuinely stumped by this. I know it’s possible, since Combat Warriors has this exact system implemented.

This is the code I used for the emotes. It is taken directly from the default Animate script and inserted into my custom one with a few changes.

game:GetService("Players").LocalPlayer.Chatted:connect(function(msg)
	print(msg)
	
	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)
	end

	if (current_pose == "Standing" and emote_list[string.lower(emote)] ~= nil) then
		play_animation(emote, 0.1)
	end

end)

script:WaitForChild("PlayEmote").OnInvoke = function(emote)
	print("BROTHER PLSSSS")
	if (current_pose == "Standing" and emote_list[string.lower(emote)] ~= nil) then
		play_animation(emote, 0.1)

		return true, current_track
	end

	-- Return false to indicate that the emote could not be played
	return false
end

I’ve never tried overriding emotes before, but whenever I make custom commands I just use TextChatCommands.

Sorry if this doesn’t help you.

Yeah, I managed to get it working myself, but since you beat me to making a reply about it, I’ll mark your reply as the solution!
And a small note for anyone else that will want to do this, name/rename your emote command so it isn’t “RBXEmoteCommand” as then you’ll get the icky red text that is default to roblox emotes!
Here’s the entire solution I came up with (this is before cleaning it up):

text_chat_service.TextChatCommands.EmoteCommand.Triggered:Connect(function(_,text)
	local emote = ""
	if (string.sub(text, 1, 3) == "/e ") then
		emote = string.sub(text, 4)
	elseif (string.sub(text, 1, 7) == "/emote ") then
		emote = string.sub(text, 8)
	end

	if (current_pose == "Standing" and emote_list[string.lower(emote)] ~= nil) then
		play_animation(emote, 0.1)
	end
end)