How would i add a Player name to a whitelist through tables

So lets say someone was to put the Name of Player Correctly in the TextBox (wouldnt work if they did) then after you click then Button it would send the Players Name they put in into a Table After that it would allow them to walk into a specific door. How would i do this?


You could use table.insert and table.remove, and check if that player is in the table, or add the player to that table with a variable and check for the variable.

I can do that part i just need to figure out on how im gonna correctly find a player then add it to the table.

Does that player need to be in the server? Or are you looking for someone in the server might be a better way to put it.

You can find the specific player in the table by doing:

local MyTable = {}


 --table.insert code here

       if table.find(MyTable, player.UserId) then



Something like this.

1 Like

In the server of the game. It would be weird for out of the game

cant really do this because im not trying to find a player on join, But manually add a player in the game itself through the textbox.

Send the Textbox .Text to the server via a remote event and loop through all the players and see if the text matches a username.

How about

local PlrTbl = game.Players:GetPlayers()
local givenPlr = alex-- for example

for i, v in pairs(PlrTbl) do
    if v == givenPlr then
        --do the adding. 

You can define the player by doing:



table.insert , to determine if that player matches the text-box, if they do, then insert that player to the table.

I presumed that you know how to get the player from the text box and send it to the script via remotes(if it is not on the same script that is)

Yeah. Ok let me explain a bit more i want to send the Username in the texbox into a serverscript to allow them to go through a door (like a whitelist)

You can manually add the player later, first you have to define the player, once you have done that, then you can manually add the player to the table depending on certain requirements, which in your case, is through the text-box.text or .Value.

Ok so lets say you got the player and fired the remote to server so(unfortunately im on mobile so it takes time rn)

local WhitelistA = {} 

RemoteEvent.OnServerEvent:Connect(function(plr, wantedPlr)
    for i, v in pairs(game.Players:GetPlayers()) do
        if v == wantedPlr then
            table.insert(WhitelistA, #WhitelistA + 1, v)

And the rest is upto you to decide what you are going to do with the table.

Note:it is necessery to have player parameter or you’ll get confused for half an hour.

Maybe try this, make this a local script under the TextBox.

local MyTable = {}
local Text = script.Parent.Text

for _,v in pairs(MyTable) do
	if Text == table.find(MyTable, Text) then
		-- Code Here

I might try something “Different” for this project but thanks for the tips guys has really helped, I just want to make something simple-ish.

This is continuation of the other part i posted. You can use the whitelist thingy by this lets say, first you gotta find a way to detect player like touched or raycast or clickdetector. I’ll use touched.

    if hit.Parent:FindFirstChild("Humanoid")  then
        local plr = hit.Parent:GetPlayerFromCharacter()
        for i, v in pairs(WhitelistA)do
            if v == plr then
                --code what ya want. 

Do you want this to be done on the server or locally?

oh my god thank you, i found this thread trying the same thing