Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

GUI seen for only certain amount of players?

Asked by 4 years ago
Edited 4 years ago

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?

2 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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.

0
Are you sure that it doesn't require string in names? It doesn't work. KoxiThePlayerPL 37 — 4y
0
Do you have Discord? It's faster to talk there. GeneratedScript 740 — 4y
0
yeah KoxiThePlayerPL 37 — 4y
Ad
Log in to vote
-1
Answered by
6zk8 95
4 years ago

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
0
If it works please put it as the answer 6zk8 95 — 4y
0
Where do I put mygui.Visible? KoxiThePlayerPL 37 — 4y
0
Inside a localscript in the GUI frame 6zk8 95 — 4y
0
It wont work because ".Find" is not a valid event for tables. It does not exist. GeneratedScript 740 — 4y
View all comments (6 more)
0
YOURGUIVARIABLEHERE.MouseButton1Click:Connect(function() { 6zk8 95 — 4y
0
But I mean, where do I put the visible property in script. Because it has to be visible and not visible too, right? KoxiThePlayerPL 37 — 4y
0
Not only that, but you saved the the table values as names and tried to get them with UserIds. GeneratedScript 740 — 4y
0
Local GUI = game.StarterGui.YOURSCREENGUI.YOURFRAME 6zk8 95 — 4y
0
Srry Im new 6zk8 95 — 4y
0
Thanks for pointing that out though 6zk8 95 — 4y

Answer this question