What does this mean?

Players.no_clu360.PlayerGui.ScreenGui.ScrollingFrame.ImageButton.LocalScript:8: Expected , got ‘else’

function onClicked(clicked)
		script.Parent.Sound:play()
		script.Parent.Parent.Parent.sidebar.start.Visible = true
		script.Parent.Parent.Parent.sidebar.info.Visible = true
	end
	else
		script.Parent.Parent.Parent.sidebar.start.Visible = false
		script.Parent.Parent.Parent.sidebar.info.Visible = false
	end		
end
script.Parent.MouseButton1Click:connect(onClicked)
1 Like

Remove the end before the else.

1 Like

It now says this

Players.no_clu360.PlayerGui.ScreenGui.ScrollingFrame.ImageButton.LocalScript:5: Expected ‘end’ (to close ‘function’ at line 1), got ‘else’

1 Like

I think the error is very obvious, you’re using some very weird syntax.

You can’t use else without having an if then beforehands.
I think you’re code was supposed to be

local open 

function onClicked(clicked)
        if not(open) then 
        open = true
		script.Parent.Sound:play()
		script.Parent.Parent.Parent.sidebar.start.Visible = true
		script.Parent.Parent.Parent.sidebar.info.Visible = true
	else
        open = false
		script.Parent.Parent.Parent.sidebar.start.Visible = false
		script.Parent.Parent.Parent.sidebar.info.Visible = false
	end		
end
script.Parent.MouseButton1Click:connect(onClicked)

Try to pay attention for super simple problems such as these.

2 Likes

I see two problems here.

  1. The first end right there just ends the function, so anything below it will error because of other ends.

  2. There seems to be no if statement, so an ‘else’ there will error, because you need to make an if statement along with it.

1 Like

im new to scripting so easy things come hard to me.

2 Likes

I personally think it’s less than ideal, especially for a novice, to do;

if not(X) then
--codeblock A
else
--codeblock B
end

It’s cleaner to just do

if X then
--codeblock B
else
--codeblock A
end

Emphasis on novice.

1 Like

It’s really more of user choice really. In a normal if statment like you gave, I would go for the second option as well since it’s simpler.
But for those open/close ui type of things, I personally prefer using not() because it’s more logical.
If you do

if open then
     open = false 
     --and other stuff
else
     open = true
    --and other stuff
end

Here you are saying: if it is open, close, if it is closed, open.
But with

if not(open) then
     open = true
     --and other stuff
else
     open = false
    --and other stuff
end

It’s kind of easier to understand for a first look, and it trasnlates into a human readable language, you’re basically saying: if it’s not open, open it, else close it. A humand would say this phrase instead of if it’s open close if it’s closed open.

Again it’s a user’s choice, and there are no problems with performance in either two situations.