Hello, I am wondering how to make a GUI but seen only for few players. I know that I have to do it by table, but how to check if player is already in it?
In contrary to the other answer, I would recommend making a localscript inside the GUI (directly inside the ScreenGUI) and doing this:
local playerTable = {KoxiThePlayerPl = true, } -- Add more names by doing TheirName = true, local Lplayer = game.Players.LocalPlayer; if(playerTable[Lplayer.Name] == true) then script.Parent.Enabled = true; return true; else script.Parent.Enabled = false; return false; end
What I did was create a dictionary with the names you wanted, then checked if that dictionary contained the names. If it did, then it would set the ScreenGUI's enabled to true.
NOTE ALL THIS CODE WILL HAVE TO BE IN A LOCAL SCRIPT!
Yes you will have to use tables. First of all, you need to create a table with people you want it to show to. For this example we are gonna use our names:
local playerTable = {"x3ooz", "KoxiThePlayerPl"}
Then you will need to find the local player and set a variable called LplayerInTable to nil:
local Lplayer = game.Players.LocalPlayer.UserId` local LplayerInTable = nil;
After that, check they are in there:
table.Find(playerTable, Lplayer)
Full script:
local playerTable = {"x3ooz", "KoxiThePlayerPl"} local Lplayer = game.Players.LocalPlayer.UserId table.Find(playerTable, Lplayer) if table.Find(playerTable, Lplayer) == true then local LplayerInTable = true return true else local LplayerIntable = false return false end