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

If plyaer is an admin, Gui isnt visible?

Asked by 6 years ago

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?)
0
I would actually recommend putting the gui in ServerStorage, and cloning it to PlayerGui. Exploiters can easily turn it on SirDerpyHerp 262 — 6y

2 answers

Log in to vote
1
Answered by 6 years ago

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

0
hi ur my dad User#21998 0 — 6y
0
this works in studio... but not in game... Gamersofthegodss 11 — 6y
0
It "works" in studio because you're using Play Solo. Do not use it. Use local servers instead. User#19524 175 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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.

0
You shouldn't give OP deprecated code...bad practice mate User#19524 175 — 6y
0
Also, if is not a loop, it is a keyword, and is also known as an if statement with if ... then. User#19524 175 — 6y

Answer this question