Need Help with the wishlist of my auto kick script

I am trying to make a auto kick script for my testing place but it is kicking me I’m new to scripting I can’t figure out the wishlist script

game.Players.PlayerAdded:Connect(function(player)
print(“Player joined, username: " … player.Name…”! Kicking user, as server is locked…")
player:Kick(“You can’t join”)
print(“Kicked!”)
end)

1 Like

Add a table with userIds named whitelist or something like that and then check whatever the user is in the list, if no then kick them.

If you don’t want to be kicked, you could try something like this:

game.Players.PlayerAdded:Connect(function(player)
	if player.Name ~= "Roozvelt_2" then
		player:Kick("You can't join")
	end
end)

If you want to add more people just add or "Example Name":

game.Players.PlayerAdded:Connect(function(player)
	if player.Name ~= "Roozvelt_2" or "Roblox" then
		player:Kick("You can't join")
	end
end)

2 Likes

Adding onto this, preferably use UserIds.
Although since it’s a test place it doesn’t really matter.

2 Likes

You can make a table or a list of players you want to kick.

This works by getting their username, but you can do it with UserIds as well.

local Players = game:GetService("Players")

local YourList = {"Example", "Example2"}

function OnPlayerAdded(Player)
	if table.find(YourList, Player) then
		Player:Kick()
	end
end
Players.PlayerAdded:Connect(OnPlayerAdded)

Not sure if you have to put table.find(YourList, Player.Name) or just Player lol. Think they both work.

2 Likes