Roblox Dance Revamp

I decided to revamp the Roblox /e system. (Like /e dance, /e laugh, /e wave, etc.)
Put the following code in a LocalScript.
Also the code is for TextChatService and on line 11 you can switch if you want /e sit or not. (My reason to revamp the /e system was to add /e sit.)
Edit: I didnt put /e point so i added it.
Edit 2: i added custom emote support so you can add custom emotes and started using tables because of @Thunder234YT (and because i had to use tables for custom emote support)
Edit 3: I removed all of the textchatcommands except for the /e one.

game:GetService("TextChatService"):WaitForChild("TextChatCommands"):WaitForChild("RBXEmoteCommand"):Destroy()
game.Players.LocalPlayer.CharacterAdded:Wait()
local RBXNothingCommand=Instance.new("TextChatCommand")
local emotes={"/emote dance","/e dance","/emote dance1","/e dance1","/emote dance2","/e dance2","/emote dance3","/e dance3","/emote laugh","/e laugh","/emote cheer","/e cheer","/emote wave","/e wave","/emote point","/e point","/emote","/e","/emote sit","/e sit"}
local IsSitCommandActivated=true
local function AddAnimation(animationlink:string,animationname:string)
	game.Players.LocalPlayer.CharacterAdded:Connect(function(character:Model)
		local stringval=Instance.new("StringValue")
		local newanim=Instance.new("Animation")
		table.insert(emotes,"/emote "..animationname)
		table.insert(emotes,"/e "..animationname)
		stringval.Name=animationname
		stringval.Parent=character:WaitForChild("Animate")
		newanim.Parent=stringval
		newanim.Name=animationname.."Anim"
		newanim.AnimationId=animationlink
		RBXNothingCommand.Triggered:Connect(function(textsource,msg)
			local player:Player=game.Players:GetPlayerByUserId(textsource.UserId)
			local humanoid:Humanoid=player.Character:WaitForChild("Humanoid")
			humanoid.Died:Connect(function()
				stringval:Destroy()
				newanim:Destroy()
			end)
			if msg~="/emote "..animationname and msg~="/e "..animationname then return end
			local animationtrack=humanoid:WaitForChild("Animator"):LoadAnimation(newanim)
			animationtrack:Play()
		end)
	end)
end
RBXNothingCommand.Parent=game.TextChatService:WaitForChild("TextChatCommands")
RBXNothingCommand.Name="RBXEmotesCommand"
RBXNothingCommand.PrimaryAlias="/emote"
RBXNothingCommand.SecondaryAlias="/e"
RBXNothingCommand.AutocompleteVisible=false
RBXNothingCommand.Triggered:Connect(function(textsource,msg)
	local player:Player=game.Players:GetPlayerByUserId(textsource.UserId)
	if msg.lower(msg)==emotes[1] or msg.lower(msg)==emotes[2] then
		local result=math.random(1,3)
		if result==1 then
			if player.Character:WaitForChild("Humanoid").RigType==Enum.HumanoidRigType.R15 then
				player.Character.Animate.PlayEmote:Invoke("dance")	
			else
				player.Character.Animate.PlayEmote:Invoke("dance1")
			end
		elseif result==2 then
			player.Character.Animate.PlayEmote:Invoke("dance2")	
		else
			player.Character.Animate.PlayEmote:Invoke("dance3")
		end	
	end
	if msg.lower(msg)==emotes[3] or msg.lower(msg)==emotes[4] then
		if player.Character:WaitForChild("Humanoid").RigType==Enum.HumanoidRigType.R15 then
			player.Character.Animate.PlayEmote:Invoke("dance")	
		else
			player.Character.Animate.PlayEmote:Invoke("dance1")
		end
	end
	if msg.lower(msg)==emotes[5] or msg.lower(msg)==emotes[6] then
		player.Character.Animate.PlayEmote:Invoke("dance2")
	end
	if msg.lower(msg)==emotes[7] or msg.lower(msg)==emotes[8] then
		player.Character.Animate.PlayEmote:Invoke("dance3")
	end
	if msg.lower(msg)==emotes[9] or msg.lower(msg)==emotes[10] then
		player.Character.Animate.PlayEmote:Invoke("laugh")
	end
	if msg.lower(msg)==emotes[11] or msg.lower(msg)==emotes[12] then
		player.Character.Animate.PlayEmote:Invoke("cheer")
	end
	if msg.lower(msg)==emotes[13] or msg.lower(msg)==emotes[14] then
		player.Character.Animate.PlayEmote:Invoke("wave")
	end
	if msg.lower(msg)==emotes[15] or msg.lower(msg)==emotes[16] then
		player.Character.Animate.PlayEmote:Invoke("point")
	end
	if msg.lower(msg)==emotes[19] or msg.lower(msg)==emotes[20] and IsSitCommandActivated==false then
		if player.Character:WaitForChild("Humanoid").RigType==Enum.HumanoidRigType.R15 then
			game:GetService("TextChatService").TextChannels.RBXSystem:DisplaySystemMessage("You do not own this emote.","Error")
		else
			game:GetService("TextChatService").TextChannels.RBXSystem:DisplaySystemMessage("Switch to your R15 avatar to play Emote.","Error")
		end
	end
	if msg.lower(msg)==emotes[19] or msg.lower(msg)==emotes[20] and IsSitCommandActivated==false then return end
	if msg.lower(msg)==emotes[19] or msg.lower(msg)==emotes[20] and IsSitCommandActivated==true then
		player.Character:WaitForChild("Humanoid").Sit=true
	end
	if msg.lower(msg)==emotes[17] or msg.lower(msg)==emotes[18] then
		game:GetService("TextChatService").TextChannels.RBXSystem:DisplaySystemMessage("Emote does not exist.","Error")
	end
	for i,v in ipairs(emotes) do
		if msg.lower(msg)==emotes[i] then return end
		if msg.lower(msg)~=emotes[i] and i>=#emotes then
			if player.Character:WaitForChild("Humanoid").RigType==Enum.HumanoidRigType.R15 then
				game:GetService("TextChatService").TextChannels.RBXSystem:DisplaySystemMessage("You do not own this emote.","Error")
			else
				game:GetService("TextChatService").TextChannels.RBXSystem:DisplaySystemMessage("Switch to your R15 avatar to play Emote.","Error")
			end
		end
	end
end)

2 Likes

You know you can just use 1 text chat command. add a local script that checks when the emote command is triggered. and if it says “/e sit” it will make the player sit

1 Like

I was trying to do that at first but there’s a lot of problems. The /e wouldnt work due to the already existing /e command so I had to disable it but that had problems too. If I disabled the already existing one I would have to recode the roblox dances back in so both the /e sit and /e commands work.

1 Like

oh i see. personally i would just edit the Animate script inside the character. also you can make your code much cleaner by using a table

1 Like

tysm for the stuff about using tables. it would be almost impossible for me to add custom emotes without using tables.

you dont need to make a variable for every text chat commands you can put it in a table and have the command set as something like

command.Name = "RBX"..commandName.."Command"
command.PrimaryAlias = "/emote "..commandName
1 Like

im going to try a diffrent approach to the one i was using before. Instead of using lots of textchatcommands im going to try and only use 1.

I did it YAY!!!

I havent tested it but try this, I hope it helps your scripting journey :grin:

game:GetService("TextChatService"):WaitForChild("TextChatCommands"):WaitForChild("RBXEmoteCommand"):Destroy()
game.Players.LocalPlayer.CharacterAdded:Wait()
local RBXNothingCommand=Instance.new("TextChatCommand")
local emotes={"dance","dance1","dance2","dance3","laugh","cheer","wave","point","sit"}
local IsSitCommandActivated=true

emoteCmd.Parent=game.TextChatService:WaitForChild("TextChatCommands")
emoteCmd.Name="RBXEmotesCommand"
emoteCmd.PrimaryAlias="/emote"
emoteCmd.SecondaryAlias="/e"
emoteCmd.AutocompleteVisible=false
emoteCmd.Triggered:Connect(function(textsource,msg)
	local player:Player=game.Players:GetPlayerByUserId(textsource.UserId)
	local emote = nil
	if string.sub(msg,1,3) == "/e " then
		emote = string.lower(string.sub(msg,4))
	elseif string.sub(msg,1,7) == "/emote " then
		emote = string.lower(string.sub(msg,8))
	end
	if emote then
		if emote ~= "" then
			if emotes[emote] then
				if emote == "dance1" then
					local result=math.random(1,3)
					if result==1 then
						if player.Character:WaitForChild("Humanoid").RigType==Enum.HumanoidRigType.R15 then
							player.Character.Animate.PlayEmote:Invoke("dance")	
						else
							player.Character.Animate.PlayEmote:Invoke("dance1")
						end
					elseif result==2 then
						player.Character.Animate.PlayEmote:Invoke("dance2")	
					else
						player.Character.Animate.PlayEmote:Invoke("dance3")
					end	
				end
				if emote == "dance1" then
					if player.Character:WaitForChild("Humanoid").RigType==Enum.HumanoidRigType.R15 then
						player.Character.Animate.PlayEmote:Invoke("dance")	
					else
						player.Character.Animate.PlayEmote:Invoke("dance1")
					end
				end
				if emote == "sit" then
					if IsSitCommandActivated then 
						player.Character:WaitForChild("Humanoid").Sit=true
					else
					return end
				end
			else
				if player.Character:WaitForChild("Humanoid").RigType==Enum.HumanoidRigType.R15 then
					game:GetService("TextChatService").TextChannels.RBXSystem:DisplaySystemMessage("You do not own this emote.","Error")
				else
					game:GetService("TextChatService").TextChannels.RBXSystem:DisplaySystemMessage("Switch to your R15 avatar to play this emote.","Error")
				end
			end
		else
			game:GetService("TextChatService").TextChannels.RBXSystem:DisplaySystemMessage("Emote does not exist.","Error")
		end
	end
end)
1 Like

nice ill try testing with your examples tomorrow!!!

1 Like