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

Why doesn't this admin GUI work?

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

✓ Accepted answer

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.

1 comment

0

THANK YOU! >:D

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