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

GUI Not Working for Me and a Few People. How could I make something that could fix it?

I'm trying to make a roblox gui only visible to me and a few friends, however the first comma in the script has an error. The error says "Expected 'then' when parsing if statement, got ',' .

Here is the Code:

if game.Players.LocalPlayer == {"ThrashIsDead","poophead27272","darkslayer741"} then
    script.Parent.Visible = true
else
    script.Parent.Visible = false

Help would be greatly appreciated. I've been struggling with this for some time now, but can't seem to figure it out.

2 answers

✓ Accepted answer

You're comparing an instance with a table. Here, use table.find :

local Table_Of_Names = {"ThrashIsDead","poophead27272","darkslayer741"};
if table.find(Table_Of_Names,game:service'Players'.LocalPlayer.Name)then
	print'Oh wow'
end;


1 comment

0

Thank you so much. This is the only method that worked. I've tried literally over a dozen different things, but it never worked for me. I'm so glad for this. I'm somewhat of a noob to scripting, I've only done it for a few months, but this gave me some insight on new methods I could try. Thank you once again for this.

You're using squiggly brackets like it's a table. Also you're comparing string to an object value. Idk if using 'or' or a comma makes a difference though.

script.Parent.MouseButton1Click:connect(function()
	if game.Players.LocalPlayer.Name == ("Edbotikx" or "poophead27272" or "darkslayer741") then
    script.Parent.Visible = true
	print"visible"
else
    script.Parent.Visible = false
	print"not"
end
end)

6 comments

0

That's not how it works

0

Well it worked for me, so care to explain Chloe?

0

Tried this, however it still shows up to random people that join. Thanks for posting though

0

it only works for you but not the two other people

0

heres an observation local a= false or 0 or nil; print(a) Notice how variable a only prints 0. This can only happen if the values before are false or nil. Notice the if statement, since the first string is not false nor nil, the value will be edbot. But if tested on every player, it will only come up with edbot only.

0

if i have to explain more i will

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