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

If plyaer is an admin, Gui isnt visible?

Im trying to make it so that if the player is an admin, the gui wouldnt be visible to them. I can't seem to find the problem though...

Thanks in advance

Admins = {['sweetlittlegirlohhl'] = true
	if Admins
	script.Parent.Parent.Visible = false
 		
	end
end?)

1 comment

0

I would actually recommend putting the gui in ServerStorage, and cloning it to PlayerGui. Exploiters can easily turn it on

2 answers

###You're checking if a dictionary equals true or is not nil. You should instead be checking if the player's name is in the dictionary, and you're missing a then. You also did not close off your dictionary correctly, and there is a random end?).

local Admins = {
    ['sweetlittlegirlohhl'] = true
}
   
if Admins[Player.Name] then -- remember to define Player
    script.Parent.Parent.Visible = false
end

3 comments

0

hi ur my dad

0

this works in studio... but not in game...

0

It "works" in studio because you're using Play Solo. Do not use it. Use local servers instead.

You have many sensible mistakes, but no worries. I got your back.

game.Players.PlayerAdded:connect(function(plr) -- When the player enters, the below code is ran.
	Admins = {"user", "user", "user"} -- Make sure to edit the "user" entries to a username
	
	for i,values in pairs(admin) do 
		if plr.Name == values then
			script.Parent.Parent.Visible = false
		end
	end
end)

This is untested, if there is an error, please look in the output and let me know about it.

If you care to read, I'll explain what the code does.

The first line says that when the player enters the game the code inside of it is executed.

The second line is essential and will define any users that should be admin.

The fourth line defines the table's values individually inside of a if loop so that it is ran by the number of values the variable, Admins contains.

The sixth line simply turns the object invisible.

2 comments

0

You shouldn't give OP deprecated code...bad practice mate

0

Also, if is not a loop, it is a keyword, and is also known as an if statement with if ... then.

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