US Trends

how to whitelist someone in my prison roblox

Use a UserId-based whitelist in a server script, not usernames. In Roblox, usernames can change, but UserIds stay the same, which makes the whitelist more reliable.

Simple setup

Put this in ServerScriptService :

lua

local Players = game:GetService("Players")

local WHITELIST = {
	[123456789] = true,
	[987654321] = true,
}

Players.PlayerAdded:Connect(function(player)
	if not WHITELIST[player.UserId] then
		player:Kick("You are not whitelisted.")
	end
end)

How to add someone

  1. Open their Roblox profile.
  2. Copy their UserId from the profile URL or page info.
  3. Add it to the WHITELIST table as a number.
  4. Save and test the game.

Why this works better

  • It prevents name-change issues.
  • It avoids the common mistake of looping through names and kicking everyone by accident.
  • It’s the standard pattern recommended in Roblox scripting discussions and tutorials.

If you want names instead

You can whitelist by player.Name, but it’s less safe because names can change. If you still use names, the check should be done with a lookup table, not a loop that kicks inside the loop.

Example with names

lua

local Players = game:GetService("Players")

local WHITELIST = {
	["YourNameHere"] = true,
	["FriendNameHere"] = true,
}

Players.PlayerAdded:Connect(function(player)
	if not WHITELIST[player.Name] then
		player:Kick("You are not whitelisted.")
	end
end)

Common mistake

A lot of people write a loop like “for every name in the whitelist, if it doesn’t match, kick the player.” That kicks players too early because the code checks the first non-match and immediately boots them.

Best choice

For a Roblox prison game, the cleanest method is:

  • whitelist by UserId ,
  • keep the script in ServerScriptService ,
  • and use player:Kick() only when the player is not approved.

TL;DR: add the player’s UserId to a whitelist table, then kick anyone whose UserId is not in it.