Whitelist script

Hello ! i was bored so i made a script to lets enter players who are in the Whitelist but not the others :slight_smile:
I prefere make a whitelist of some players than a banlist of every others roblox players.
I made this script because i made a public game but i just want to lets some players enter and no more.
Here is the script

Whitelist= "Mimibienv", "zawoitch", "laserrole", "catlooping89", "Feabrey", "Prithvi111", "HyperNovaWolf"

game.Players.PlayerAdded:Connect(function(plr)
	if plr.Name == Whitelist then
		print("Access Autorised for "..plr.Name)
	else
		plr:kick("4CC3SS D3N13D F0R "..plr.Name..". PL34S3 C0M3 B4CK L4T3R")
	end
	
end)

ps: i write fast with a lot of fails in my words so… don’t juge meh :frowning:

And it work perfectly C:
Have a good day,

Mimibienv

2 Likes

yes, but, its a cool creation so… it can be in cool creation

2 Likes

On this bit there is not a problem with it but I noticed you had the = right next to the Whitelist. I normally just space it out to make it look better and neater. Good job on it by the way. :slight_smile:

Seems decent. Here’s some improvements:

  1. Instead of just storing the names in the whitelist table, use their UserId instead.

  2. When checking a player to see if they are whitelisted, use table.find().

You are only whitelisting yourself

instead of

Whitelist= "Mimibienv", "zawoitch", "laserrole", "catlooping89", "Feabrey", "Prithvi111", "HyperNovaWolf"

and

if plr.Name == Whitelist then

you should do

Whitelist = {"Mimibienv", "zawoitch", "laserrole", "catlooping89", "Feabrey", "Prithvi111", "HyperNovaWolf"}

and

if table.find(Whitelist, plr.Name) then

So, this would be the script, fixed

Whitelist = {"Mimibienv", "zawoitch", "laserrole", "catlooping89", "Feabrey", "Prithvi111", "HyperNovaWolf"}

game.Players.PlayerAdded:Connect(function(plr)
	if table.find(Whitelist, plr.Name) then
		print("Access Authorized for ".. plr.Name)
	else
		plr:kick("Access denied for "..plr.Name..". Please retry later")
	end
end)

Also, don’t use crazy 1337SP34K when talking, some people might not understand what it’s saying, lol.

1 Like

lol yes,
3 = E
4 = A
1 = I
etc…
sorry, i was bored lol C:

Yes But there is a lot of possibility to script this and i used one.

Whitelist myself ? uhh… just change in game settings to private :roll_eyes:

ok then uhh

Whitelist = "Mimibienv", "zawoitch", "laserrole", "catlooping89", "Feabrey", "Prithvi111", "HyperNovaWolf"

No more fails :slight_smile:

That only whitelists yourself; everything after is referenced to nothing. You will need to put this in an array to whitelist everyone else.

Try this, using Pairs can help with these kind of things.

local Whitelist = {"Mimibienv", "zawoitch", "laserrole", "catlooping89", "Feabrey", "Prithvi111", "HyperNovaWolf"}

game.Players.PlayerAdded:Connect(function(Player)
	for i,v in pairs(Whitelist) do
		if Player.Name == v then
			print("Access Autorised for "..Player.Name)
		else
			Player:kick("4CC3SS D3N13D F0R "..Player.Name..". PL34S3 C0M3 B4CK L4T3R")
		end
	end	
end)

If you’re going to give away this script, then it goes into #resources:community-resources.

No need to loop, you can just use table.find().

I never used table.find() :flushed: But at least it fixes the script the person wants.

You would use table.find() like this:

table.find(table, value)

yeah, it will be better lol…

Making a list and using table.find() will help you a lot!
I made this code, is working I tested it.

Code
Whitelist = {"Mimibienv", "zawoitch", "laserrole", "catlooping89", "Feabrey", "Prithvi111", "HyperNovaWolf"}

game.Players.PlayerAdded:Connect(function(plr)
	if table.find(Whitelist,plr.Name) then
		print("Access Autorised for "..plr.Name)
	else
		plr:kick("4CC3SS D3N13D F0R "..plr.Name..". PL34S3 C0M3 B4CK L4T3R")
	end

end)
1 Like

If you use for i,v in pairs(Whitelist) at the moment that the name is wrong it will kick you.

I recommend something like this

local Whitelist = {
	["Mimibienv"] = true,
}

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Player)
	if Whitelist[Player.Name] then
		warn'Whitelisted'
	else
		Player:Kick("You're not whitelisted")
	end
end)