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?
GUI seen for only certain amount of players?
2 answers
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
10 comments
If it works please put it as the answer
Where do I put mygui.Visible?
Inside a localscript in the GUI frame
It wont work because ".Find" is not a valid event for tables. It does not exist.
YOURGUIVARIABLEHERE.MouseButton1Click:Connect(function() {
But I mean, where do I put the visible property in script. Because it has to be visible and not visible too, right?
Not only that, but you saved the the table values as names and tried to get them with UserIds.
Local GUI = game.StarterGui.YOURSCREENGUI.YOURFRAME
Srry Im new
Thanks for pointing that out though
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
Are you sure that it doesn't require string in names? It doesn't work.
Do you have Discord? It's faster to talk there.
yeah