Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I am trying to make a gui show only to specific people, and don't know how to?

I have no clue how to do it and was experimenting so see if it will work. My script doesn't work, and I am sure most of it doesn't exist. Here is my code.

script.Parent.Visible = false
local Admins = {"Sadwowow21"}
if Player.name == Admins then
	script.Parent.Visible = true
end

2 answers

✓ Accepted answer

So what I would do is create a Dictionary (which is basically an array but each index [or value] is assigned a value).

Let me demonstrate:

local Player = game.Players.LocalPlayer;
local dictionary = {
	Admin1 = true,
	Admin2 = true
};

print(dictionary["Admin1"]); -- true

Why this is better is because now, you can set different people to have different "staff" levels.

local Player = game.Players.LocalPlayer;
local dictionary = {
	Username1 = "Administrator",
	Username2 = "Moderator"
};

print(dictionary["Username1"]); -- "Administrator"

So, how do you implement this into your script?

local Player = game.Players.LocalPlayer;
script.Parent.Visible = false;
local Admins = {
	Sadwowow21 = true,
	-- Add more names, and set them to true
};
if Admins[Player.Name] then
    script.Parent.Visible = true;
end

If you further wanted to add more and have it only show for Administrators:

local Player = game.Players.LocalPlayer;
script.Parent.Visible = false;
local Admins = {
	Sadwowow21 = "Administrator",
	TestUser = "Moderator"
	-- Add more names, and set them to true
};

if Admins[Player.Name] == "Administrator" then -- Even though TestUser is in the dictionary, they are ignored because they are set as a "Moderator" and not an "Administrator", which is what we looked for with this line.
    script.Parent.Visible = true;
end

13 comments

0

thank you, but it isn't showing still

0

I just tested it, and it did work. Which one are you using? If you don't want to get into dictionaries, I'd recommend looping, as Filipalla answered.

0

Edit: The reason it's not working is because you need to use a LocalScript. You need to have the LocalScript inside the GUI. Then try again.

0

ok

0

I keep getting this warning sign 18:19:28.744 - Players.SadWowow21.PlayerGui.ScreenGui.TextButton.LocalScript:6: attempt to index global 'Player' (a nil value)

1

ah so you never declared LocalPlayer? Okay, I'll update the answer.

0

I updated it so it'll work.

0

oh thx so much

0

If it worked, can you please mark it as answer? Thanks.

0

Oof, He Didn't Do That :/ Isn't That Against The Rules? (I'm Not Going To Report Him Or Anything Like That, Just Asking)

0

I don't know lol.

0

???

0

Thanks Sadwowow21.

You are trying to compare a string with a table, what you actually want to do is get the strings in the table like so

script.Parent.Visible = false
local Admins = {"Sadwowow21"}
for _, Admin in pairs(Admins) do
	if Player.Name == Admin then
		script.Parent.Visible = true
	end
end

Note: Using the UserID is probably better for this

1 comment

0

would it be a normal script or local script? because I am using normal script and it isn't showing

This discussion is preserved as it was. New answers, comments, and votes are closed.