Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how to filter chat im using commands and i need the chat to filter it?

so i am making commands and i want it if i type / then it wont end up in chat is there any way to do that? so like if i know that it starts with a / how do i disable it from being chatted?

3 answers

✓ Accepted answer

You can start by following this article: https://developer.roblox.com/en-us/articles/Lua-Chat-System

Basically you need to copy all the contents of chat when playtesting the game, stopping the playtest and then pasting the stuff into the empty chat. Then set the scriptable proprrty of chat to true. You can then follow the instructions in the article to create the script you want.

.


local function Run(ChatService)
	local function createPart(speakerName, message, channelName)
		if string.sub(message, 1, 5) == "/part" then
			local newPart = Instance.new("Part")
			newPart.Parent = game.Workspace
			return true
		end
		return false
	end
 
	ChatService:RegisterProcessCommandsFunction("createPart", createPart)
end
 
return Run

as you can see, we create a modulescript, and put it into the chatmodules folder. in the module we have a function called run, and do stuff in the function. we then create a function in the function called create part, which takes in the message, player who chatted it, and the channel or where its been chat. we then get the message and string.sub ("/part",1,5), which checks if the first five characters (1,5) is /part.

If it is, we then create a part, and return true. After that is the end of the function create part.

After declaring the function create part, we have to pass it through the event ChatService:RegisterProcessCommandsFunction.

Hope this helps!

9 comments

1

is this in a server script? and i dont see where it mutes the player

1

also where do u put it?

1

and how does the function get the speakername,message, and channel name?

1

you put the script into the chatmodules folder. It is a module script. The function gets the speakername, message, and channel name because of the chat function we connected the create part function to. see line 11, ChatService:RegisterProcessCommandsFunction("createPart", createPart) the seond

0

when i paste the chat into the chat and disable LoadDefaltChat non of the chat is there :/ is that normal?

0

so i just made it so load defalt chat is true

0

so it works but in my thing it has an error when i put my code in, it seems that you cant really use remote events in module scripts is there any way around this because what i do with it is i make a system message to all / the person who did the command

1

im not really sure, ive never done chat command filtering before. maybe you could try using bindable events and fire that and have another script listen to the bindable event and then fire the remote event?

0

ok thanks ill post a different question about it

U could try making a seperate admin panel, that only takes commands.

1 comment

0

U wouldnt be able to use the chatted event tho

This discussion is preserved as it was. New answers, comments, and votes are closed.