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

whats wrong with my script??? end expected near else

Asked by
5xbh 17
3 years ago

so, i was scripting and i noticed that it wanted me to put an end near "else", i tried doing that in many different ways and nothing worked. can someone help me out and correct my code?

script.Parent.MouseButton1Click:Connect(function()
    script.Parent.ColorGradientFrame.Visible = true
    script.Parent.ColorGradientFrame2.Visible = true
    script.Parent.DarknessGradientFrame.Visible = true
    script.Parent.DarknessGradientFrame2.Visible = true
    else
    script.Parent.ColorGradientFrame.Visible = false
    script.Parent.ColorGradientFrame2.Visible = false
    script.Parent.DarknessGradientFrame.Visible = false
    script.Parent.DarknessGradientFrame2.Visible = false
end)
0
You include else on line 6 but there is no if statement, that is the problem. Try replacing every true on lines 2-5 with "not script.Parent.blah.Visible". If Visible = true, it will turn false since not true = false. If Visible = false, it will turn true since not false = true Omq_ItzJasmin 666 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

Your problem is that you used else with no if statement. Else should be used in situations where there are two possible outcomes that rely on a statement being true or false. I'm going to assume that you just want to make the color gradient visible and invisible per click. That would look like this:

script.Parent.MouseButton1Click:Connect(function()
    if not script.Parent.ColorGradient.Frame.Visible then
        script.Parent.ColorGradientFrame.Visible = true
        script.Parent.ColorGradientFrame2.Visible = true
        script.Parent.DarknessGradientFrame.Visible = true
        script.Parent.DarknessGradientFrame2.Visible = true
    else -- else means that any situation that the Frame isn't visible, the following lines will run
        script.Parent.ColorGradientFrame.Visible = false
        script.Parent.ColorGradientFrame2.Visible = false
        script.Parent.DarknessGradientFrame.Visible = false
        script.Parent.DarknessGradientFrame2.Visible = false
    end
end)

Comment if you have any questions as to how that works. Hope I helped!

1
Great answer! I finally figured it out where to place the "not" on if statements lol funny...... Xapelize 2658 — 3y
Ad

Answer this question