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

Making a GUI appear for white-listed people?

So, I tried to make a gui appear for white-listed people but it kinda stopped working for some reason? It's a local script, the parent of the script is a frame then the script will make it visible or not visible, I put multiple people into the whitelist, whenever I go into the game it just won't show up for me, even though my name's in the whitelist.

local player = game.Players.LocalPlayer

if player.Name == {"Disgreace","Username","Username","Username"} then
   
  script.Parent.Parent.Close.Visible = false
script.Parent.Visible = true
else
	script.Parent.Visible = false
	  script.Parent.Parent.Close.Visible = false
end

It's pretty much like I said, it stopped working after a while for some reason, used to work. Don't know why and the reason for the "script.Parent.Parent.Close.Visible = false" is because the close button isn't in the same frame as the script for the whitelist, so yeah. Many thanks if there's a way to solve this.

This is pretty much how it's like.

StarterGui ScreenGui Close

Frame Whitelist Other stuff ScrollingFrame

1 answer

✓ Accepted answer

You cannot compare a string to a table. However, you can write a function to check if the player is whitelisted by itinerating through the table checking if the username there matches the player's name. If the player's username can be found in the table, return true. Otherwise, return false.


local player = game.Players.LocalPlayer
local Whitelist = {
	"Disgreace",
	"Username",
	"Username",
	"Username",
}

local function IsWhitelisted()
	local IsWhite = false

	for I,v in pairs(Whitelist) do
		if player.Name == v then
			IsWhite = true
			break
		end
	end
	
	return IsWhite
end

if IsWhitelisted() then
	script.Parent.Parent.Close.Visible = false
	script.Parent.Visible = true
else
	script.Parent.Visible = false
	script.Parent.Parent.Close.Visible = false
end

2 comments

0

Hmm, this doesn't seen to work. Not sure why, though! But thanks for trying to help!

0

Great! I found out how to fix my problem, I typed something wrong, sorry!

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