Hey there!
I’ve recently been determined to find a way and make it so if a player spams - they automatically get kicked; however I can’t find a solution.
Therefor, that brings me here today with:
How would I make it so if a player sends the Same message within a matter of seconds 5 or more times they automatically get kicked for “AK | Spamming.”?
1 Like
I believe you could do this by create some variables:
-
A while true do
loop for resetting the “MessagesPerSecond” variable
-
“Seconds” will be the cooldown inside the loop
-
“DuplicateMessage” for now will be nil
, if there’s no message that was sent during the loop, we can set its value to be the Msg
variable
-
“MessagesPerSecond” will be the amount of times that message is counted, if it reaches over the “SpamLimit” count then it’ll kick the player
local Seconds = 5
local SpamLimit = 10
game.Players.PlayerAdded:Connect(function(Player)
local DuplicateMessage
local MessagesPerSecond = 0
Player.Chatted:Connect(function(Msg)
if not DuplicateMessage then
DuplicateMessage = Msg
elseif DuplicateMessage == Msg then
MessagesPerSecond += 1
if MessagesPerSecond > SpamLimit then
Player:Kick("AK: | Spamming.")
end
end
end)
while true do
wait(Seconds)
MessagesPerSecond = 0
DuplicateMessage = nil
end
end)
4 Likes
I have a perm ban system where even if they change their name they are still banned here out both scripts in ServerScriptService:
-- //ServerScript // Name: Function Handler
local GetList = game.ReplicatedStorage:WaitForChild("GetList")
local banList = {} -- Add the players User ID in here with no quotes.
GetList.OnInvoke = function(player)
for keyBan, Ban in pairs(banList) do
if Ban == player.UserId then -- If ban is a players User ID and they joined.
print(player.Name.." Is In The Ban List!")
return true
else
print(player.Name.." Is Not In The Ban List!")
end
end
end
-- //ServerScript // Name: BanScript
local GetList = game.ReplicatedStorage:WaitForChild("GetList")
game.Players.PlayerAdded:Connect(function(player)
local isPlayerBanned = GetList:Invoke(player)
if isPlayerBanned == true then
player:Kick("You Have Been Perm Banned For One Of These Reasons: ".. -- You can make these reasons anything.
"Hacking, "..
"Swearing, "..
"Inappropriate Content, "..
"False Claiming As Rank, "..
"Random Ban, "..
"Random Killing, "..
"False Claiming For Hacking, "..
"Scamming"
)
end
end)
3 Likes