debris = game:GetService("Debris")
function thread(func) Spawn(func, 0) end
unit = 6
function onPlayerEntered(player)
local chats = 1
local warns = 2
player.Chatted:connect(function (msg, rec) chats = chats + 1 end)
while player.Parent do
chats = 0
wait(unit)
if chats > 1*unit and chats < 2*unit then
if warns > 2 then
player:kick()
else
local m = Instance.new("Message", player:FindFirstChild("PlayerGui"))
m.Text = "If You Flood The Chat Again, You Will Be Kicked Automatically."
debris:AddItem(m, 3)
warns = warns + 1
end
elseif chats >= 2*unit then
player:kick()
end
end
end
game.Players.PlayerAdded:connect(onPlayerEntered)
✓ ANSWER ACCEPTED
I'm trying to get this to work as a local script, is it posible? it works as normal script?
2 answers
✓ Accepted answer
Try changing line 28 in that code block to this:
Game.Players.ChildAdded:connect(function(plr)
if plr:IsA("Player") then
onPlayerEntered(plr)
end
end)
Like RedCombee said, PlayerAdded doesn't fire in LocalScripts.
I added it to my main, anyways, thanks for letting me know :)
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
Please place this in a code black.
Done.
You can't use the PlayerAdded event in a local script as far as I know.
I do have added the players in another script, i don't know if this script works local, if it get changed, i don't need on entered.