Why do my elseif is invalid again

  1. What do you want to achieve?
    I want it so if I click the button and my name is achdef the PASS UI do not show up.

  2. What is the issue? Include screenshots / videos if possible!

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried doing else, else if etc and even using a table.

local Open = script.Parent
local AdminUI = script.Parent.Parent
local Pass = AdminUI.Pass

game.Players.PlayerAdded:Connect(function(plr)
Open.MouseButton1Click:Connect(function()
Pass.Visible = true
elseif plr.Name == "achdef" then
Pass.Visible = false
print("debugging")
  end
 end)
end

elseif or else can not be used without an if statement, like i mentioned in your previous topic as well. I’d suggest you to take a look at the conditional structures in Luau.
Reference link: Conditional Structures

You should’ve pasted the script here instead of sending a distorted image

My end return as a error once I did your if statement

I’m just saying, it will be so much easier to help if you just took a look at the posting guidelines

Yeah, please take your time and go through the article I linked above, lol.
Syntax for if statement is:

if statement then
    result
elseif statement then
    other result
else
    last result
end
1 Like

Proper use of elseif

if condition then
   -- do stuff
elseif not condition then
   -- do stuff
end

You cannot use it outside an if statement

A PlayerAdded event is unnecessary, you can just use MouseButton1Click

local Player = game:GetService('Players').LocalPlayer

Open.MouseButton1Click:Connect(function()
    if Player.Name == 'achdef' then
        Pass.Visible = false
    else
        Pass.Visible = true
    end
end)

Critics actually do help. They give you feedback on things like when you post terrible quality images of code. I can barely read it.

Don’t shame them because they point out flaws in your post. Use those points to make your future posts better and more understandable.

Like many other people have said, elseif can not be used without embedding it in an if statement.

2 Likes

It may be blurry, but I can read it fine