I’m making a commands module where everything is fully server-sided (because of hackers/exploiters obviously)
I want to make a system where when you send a command, it hides the message
I have a player.Chatted base because that’s the only reliable server connection in this case
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
local message = msg:split(" ")
local commandWithPrefix = message[1]
local usedPrefix
for _, v in Prefixes do
if commandWithPrefix:sub(1, 1) == v then
usedPrefix = v
break
end
end
if not usedPrefix then return end
local command = string.lower(commandWithPrefix:split(usedPrefix)[2])
local foundCommand
for customCommand, _ in CustomCommands do
if customCommand:lower() ~= command then continue end
foundCommand = CustomCommands[customCommand].Function
break
end
for currentCommand, _ in getCommands() do
if currentCommand:lower() ~= command then continue end
foundCommand = getCommands()[currentCommand]
break
end
if not foundCommand then return end
local args = message
table.remove(args, 1)
foundCommand(player, args, msg)
end)
end)
Can anyone else help me? I know how to filter messages with server-client communication. Though, I want to keep the module safe to use with no exploit threats.
Edit: Updated Information:
Using this code:
local shouldHideMessage = false
game.Chat:RegisterChatCallback("OnServerReceivingMessage", function(message)
task.wait()
return shouldHideMessage
end)
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
if Random.new():NextInteger(1, 2) == 1 then --give 50/50 chance of appearing the message lol
shouldHideMessage = true
else
shouldHideMessage = false
end
end)
end)
Works great for LegacyChatService.
However, I still want to make it compatible with TextChatService and not just LegacyChatService.
roblox didnt add Event on server to recieve messages (at least i tried connecting to events like .MessageRecieved on server but no hope it wasnt fired at all)