Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

1 comment

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

4 answers

✓ Accepted answer

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)

1 comment

0

or you can do plr:Kick("I don't want you in my game!")

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

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)

1 comment

0

I made a mistake. put ("haha") after :Kick. It'll look like this: :Kick("haha")

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.