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

Why will this not work? It says error on line 1! Is there a problem with the 'and' system?

Asked by 7 years ago

Ok... So the problem. 21:03:24.438 - Players.Player1.PlayerGui.ScreenGui.Menu.Choices.Script:11: 'end' expected (to close 'function' at line 1) near '<eof>'

This is the script:

function onButtonClicked()
if script.Parent.Drink.Value == No and
    script.Parent.Main.Value == No and
    script.Parent.Pudding.Value == No and
    script.Parent.Snack.Value == No and
    script.Parent.Starter.Value == No then
    script.Parent.Parent.Not_selected.Visible = true else
    script.Parent.Value.Value = true
end

script.Parent.Parent.Submit.MouseButton1Click:Connect(onButtonClicked)> 

So... I don't really know what to say. Can you help me? (If I have to, I'll send screenshots on skype/discord.

1
You only have 1 end. You have to end both the function and the if statement. Add another end after line 9. Programical 653 — 7y
0
you have to close the if statement abnotaddable 920 — 7y

2 answers

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago
function onButtonClicked()
if script.Parent.Drink.Value == No and
    script.Parent.Main.Value == No and
    script.Parent.Pudding.Value == No and
    script.Parent.Snack.Value == No and
    script.Parent.Starter.Value == No then
    script.Parent.Parent.Not_selected.Visible = true else
    script.Parent.Value.Value = true
end

script.Parent.Parent.Submit.MouseButton1Click:Connect(onButtonClicked)

On line #07 on the post you forgot to put a 'then' after the 'true' and before the 'else'. Simple mistake really. Not sure what the symbol after line #11 was for, but that shouldn't be there. Also, to make the script just a tiny bit more clean, try this script:

script.Parent.Parent.Submit.MouseButton1Click:connect(function()
if script.Parent.Drink.Value == No and
    script.Parent.Main.Value == No and
    script.Parent.Pudding.Value == No and
    script.Parent.Snack.Value == No and
    script.Parent.Starter.Value == No then
    script.Parent.Parent.Not_selected.Visible = true else
    script.Parent.Value.Value = true
end)

This simply does the same thing with shaving off a line. In my opinion, every extra line counts. Hope this works and if not let me know please!

0
"then else" is not a thing. Programical 653 — 7y
0
Oh my wait a second SchonATL 15 — 7y
0
I'll change that... Hope this works. Magnetic_Aviator 21 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

I appreciate all your answers, but I realised the closest to fixing the problem was the answer I chose. This is the new script:

function onButtonClicked()
if script.Parent.Drink.Value == ("No") and
    script.Parent.Main.Value == ("No") and
    script.Parent.Pudding.Value == ("No") and
    script.Parent.Snack.Value == ("No") and
    script.Parent.Starter.Value == ("No") then
    script.Parent.Parent.Not_selected.Visible = true else
    script.Parent.Value.Value = true
end
end
script.Parent.Parent.Submit.MouseButton1Click:Connect(onButtonClicked)

Answer this question