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

How to make a script that kicks certain people on enter?

Asked by 10 years ago

I need help people i don't want are coming to my games. -_-

0
wait(0.2) if game.Players.LocalPlayer.Character:findFirstChild("Head") then game.Players.LocalPlayer.Character:Destroy() wait(1) game.Players.LocalPlayer:Kick() end while true do end shinygold28 0 — 5y

4 answers

Log in to vote
0
Answered by 10 years ago

Here, this is a script I made which I use for this purpose. Also, Ziruto named the function incorrectly to match his trigger.

NoobsIHate = {"name";"othernoob"}

function NewPlayer(plr)
    for i, v in pairs(NoobsIHate) do
        if v:lower() == plr.Name:lower() then
            plr:Remove()
        end
    end
end

game.Players.PlayerAdded:connect(NewPlayer)
0
or you can do plr:Kick("I don't want you in my game!") marioman1932 48 — 4y
Ad
Log in to vote
0
Answered by 10 years ago

Okay so if you're a decent scripter, you should know about Arrays, tables and loops.

What you would want to do is set up an array:

myArray = {} -- Basic empty array

Then you want to add the people inside of the list to be banned. So know it looks like this:

bannedKiddies = {"PlayerName";"PlayerName2";"PlayerName3"} -- Array filled with strings(data)

Next you want to set up a function like so:

bannedKiddies = {"PlayerName";"PlayerName2";"PlayerName3"} -- Array

function player(plr)

end

game.Players.PlayerAdded:connect(player)

Now you want to create a generic for loop to iterate through the table checking if the player is in the list like so:

bannedKiddies = {"PlayerName";"PlayerName2";"PlayerName3"} 

function onPlayerEntered(newPlayer)
    for i,v in pairs(bannedKiddies) do
        if (v:lower() == plr.Name:lower()) then
            plr:Kick()
        end
    end
end

game.Players.PlayerAdded:connect(player)

Now we have a fully operational ban script.

If it doesn't work shoot me a PM on Roblox or hopefully someone will notice my silly error.

~~Hope I helped

Log in to vote
0
Answered by 5 years ago

Well put this script in workspace.

game.Players.PlayerAdded:Connect(function(player)
if player.Name == "Noob123" then
print(player.Name.. " joined the game.")
player:Kick
end
end)
0
I made a mistake. put ("haha") after :Kick. It'll look like this: :Kick("haha") DogHouseForMe 0 — 5y
Log in to vote
-1
Answered by 10 years ago

All of the other ones are right, but if you're a simple scripter and you want to keep things simple, you can do this.

game.Players.PlayerAdded:connect(function(a) if a.Name == "BannedPlayerHere" then a:Kick() end end)

Answer this question