I need help people i don't want are coming to my games. -_-
Here, this is a script I made which I use for this purpose. Also, Ziruto named the function incorrectly to match his trigger.
01 | NoobsIHate = { "name" ; "othernoob" } |
02 |
03 | function NewPlayer(plr) |
04 | for i, v in pairs (NoobsIHate) do |
05 | if v:lower() = = plr.Name:lower() then |
06 | plr:Remove() |
07 | end |
08 | end |
09 | end |
10 |
11 | game.Players.PlayerAdded:connect(NewPlayer) |
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:
1 | myArray = { } -- Basic empty array |
Then you want to add the people inside of the list to be banned. So know it looks like this:
1 | bannedKiddies = { "PlayerName" ; "PlayerName2" ; "PlayerName3" } -- Array filled with strings(data) |
Next you want to set up a function like so:
1 | bannedKiddies = { "PlayerName" ; "PlayerName2" ; "PlayerName3" } -- Array |
2 |
3 | function player(plr) |
4 |
5 | end |
6 |
7 | 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:
01 | bannedKiddies = { "PlayerName" ; "PlayerName2" ; "PlayerName3" } |
02 |
03 | function onPlayerEntered(newPlayer) |
04 | for i,v in pairs (bannedKiddies) do |
05 | if (v:lower() = = plr.Name:lower()) then |
06 | plr:Kick() |
07 | end |
08 | end |
09 | end |
10 |
11 | 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
Well put this script in workspace.
1 | game.Players.PlayerAdded:Connect( function (player) |
2 | if player.Name = = "Noob123" then |
3 | print (player.Name.. " joined the game." ) |
4 | player:Kick |
5 | end |
6 | end ) |
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)