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

I dont understand my problem when writing this script with the then underline?

Asked by 5 years ago
local close = script.Parent.Close
local kartsGui = script.Parent


if close.MouseButton1Click:Connect(function()then
     script.Parent.Visible = false 
end)end``

I keep getting a red line under then but don't understand how to fix it

0
script.Parent.MouseButton1Click:Connect(function() xsupersonicfan7789 10 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.
script.Parent.MouseButton1Click:Connect(function()
         if TestVar == true then
              script.Parent.Visible = false
         end
end)
Ad
Log in to vote
0
Answered by 5 years ago

You do not need to check if "close" has been clicked because you cant have a if statement and a function in the same line.

Instead of:

if close.MouseButton1Click:Connect(function()then
    script.Parent.Visible = false
end)end

You have to do:

close.MouseButton1Click:Connect(function()
    script.Parent.Visible = false
end)

Answer this question