How do I delete any chat message containing a /?
you can detect it like so :
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
local Gsub = string.gsub(msg,"/","")
end)
end)
or
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
local Split = string.split(msg,"/")
end)
end)
GSUB will replace any “/” in the msg by “” which is nothing.
SPLIT will split the msg whenever there is a /
Ok, thanks! Do i put this in a serverscript?
i just gave you an example,
that wouldn’t delete the chat message
- Do a test and copy
ChatModules
fromChat
, then stop the test and paste it in the same location.
- Open
ChatCommandsTeller
and go to line 50. - Place this
if message:find("/") then
return true
end
Final:
As shown above with /help
, the message will not be sent if the function returns true
.
https://developer.roblox.com/en-us/api-reference/function/Chat/RegisterChatCallback
In the following script messages are blocked if they begin with a colon ‘:’ character.