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

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

Asked by 4 years ago

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

Log in to vote
0
Answered by 4 years ago

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;


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. ThrashIsDead 4 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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)
0
That's not how it works SoftlockedUnderZero 668 — 4y
0
Well it worked for me, so care to explain Chloe? Edbotikx 99 — 4y
0
Tried this, however it still shows up to random people that join. Thanks for posting though ThrashIsDead 4 — 4y
0
it only works for you but not the two other people SoftlockedUnderZero 668 — 4y
View all comments (2 more)
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. SoftlockedUnderZero 668 — 4y
0
if i have to explain more i will SoftlockedUnderZero 668 — 4y

Answer this question