How to stop players from crashing my game using a :clean spam?

  1. What do you want to achieve? I want players to stop crashing my game by spamming :clean through a script.

  2. What is the issue? Players will use an executor like Synapse to execute a spam script, crashing the game.

  3. What solutions have you tried so far? I’ve tried one solution, but it only works if the player actually types in :clean manually.

The Script:

local prefix = ":"

local msg = (prefix .."clean"):rep(10000)

for i = 1, 100 do
    game.Players:Chat(msg)
end
3 Likes

If you’re using an admin like Kohls Admin you should be able to just revoke their permission to use the Clean command. Especially if they don’t have a reason to use it.

Also this exact code has been asked in a similar question. So I suggest checking out this post.

2 Likes

I still need a full solution, the game still lags even when I followed the steps in the linked thread.

You can try kicking people whose chat message is obnoxiously long, or if their message contains a blacklisted word.

This might not be the best solution, but here is a possible implementation:

local players = game:GetService("Players")

local function isBlacklistedContent(content)
    if (#content > 255) then
        return true
    elseif (content:match(":clean")) then
        return true
    end

    return false
end

local function playerChatted(player)
    return function(message)
        if isBlacklistedContent(message) then
            player:Kick()
        end
    end
end

local function playerAdded(player)
    player.Chatted:Connect(playerChatted(player))
end

That does not prevent the lag. I tried an alternate version of it along with yours, and it seems that it doesn’t work.

If you’re using a free model admin I suggest just removing it at this point. The issue is likely being caused entirely by the admin if you’re using one and it may be better to write your own.

For future reference:
Only connect .Chatted signals for people who are admin.

You could try limiting certain commands to 1 per message.

local blacklist = {":clean"}
for _,v in ipairs(blacklist) do
    local i= string.find(msg,v)
    if i and string.find(msg,v,i+#v) then
        --illegal message
    end
end

I had suggested this (see my code block above) and It appeared to not have worked. Your code uses a very similar method so I don’t think it will work either? Not sure, but it likely will not.

It won’t prevent lag if they don’t actually kick or discard the message before parsing it to the admin script, which is probably the issue here.

Also, 100 character long array of a heavy command is more than enough to cause issues. You shouldn’t be checking for general message length but occurances of specific commands.

My confusion here is that even if I disable :clean, it’ll still spam. I looked into it and if the exploiter just removes the prefix, they can still crash a server with any message (doesn’t have to be a command).

Length operator is MUCH faster than the :match method.

Also I have noted this.

Try removing your admin if you have one implemented. Then try seeing if it crashes the server?

I have. It still crashes the server.

Are you sure its crashing the server, and not just you testing it. It could be you’re just crashing your self.

Then it has probably nothing to do with the admin script. Check if another function listens to your chat or just try limiting the chat length.

How do I check if another function listens to my chat? Limiting the chat length does not work.

Search all scripts for this: “.Chatted”

Especially server scripts.

I think you can make a cooldown for that with debounce

I’m on a plain baseplate, it’s still happening.

Try running it on a server to see if it still happens. Also try joining with an alt or a friend and make them send the message to see if it affects you.