Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

I'm trying to get this to work as a local script, is it posible? it works as normal script?

Asked by 9 years ago
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)
0
Please place this in a code black. M39a9am3R 3210 — 9y
0
Done. Master3395 10 — 9y
0
You can't use the PlayerAdded event in a local script as far as I know. RedCombee 585 — 9y
0
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. Master3395 10 — 9y

2 answers

Log in to vote
0
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

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.

Ad
Log in to vote
0
Answered by 9 years ago

I added it to my main, anyways, thanks for letting me know :)

Answer this question