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

Why doesn't this admin GUI work?

Asked by 10 years ago

I used this script in a frame. The frame holds a bunch of admin GUIs. But, for some reason it doesn't work.

admins = {"Player"}

playerName = script.Parent.Parent.Parent.Parent.Name

while wait() do
    wait(.1)
    if playerName == admins then
        script.Parent.Visible = true
    end
    print(playerName)
end

1 answer

Log in to vote
0
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
10 years ago

You see, you're are comparing a string to a table, which does not work.

A table is like a list of strings, numbers, values, or variables.

example = {"I", "Like", "The Numbers", 5, 10, 15}

You want to compare the string or "playerName" to a value in the table, to do this you will need a loop. More specifically, a for loop. A for loop will go through all the values of the table or after a specified number of steps, and stop at the end.

So, for your script, you want to have the below code;

for _,v in pairs(admins) do --For every admin name there is in that list, the script will do something.
    if playerName == v then --If the playerName and the value in the table match up, then the script will do something.
        script.Parent.Visible = true --Show the Gui
    end
end

Really, you do not need the while loop, that will only add lag to your game (might not be noticeable). Just put the script I provided above into lines 5-11 and you should have a working script.

0
THANK YOU! >:D adspace44 20 — 10y
Ad

Answer this question