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

My open/close tab doesn't work, what can be done to fix it?

Asked by 8 years ago

I tried to script a button that will open and close a frame but despite the ScreenGUI frames appear on the screen, the button won't function (open and close on click)

local Button = script.Parent.AddAssignment.CloseFrame.CloseButton

Frame = script.Parent.AddAssignment.Frame

function onClick()
    if Frame.Visible == false then
        Frame.Visible = true
    elseif Frame.Visible == true then
        Frame.Visible = false

    end
end

Button.MouseButton1Click.connect(onClick)

Note: All the objects above exist in the workspace

1
Frame.Visible = not Frame.Visible will do the same thing as your if's theCJarmy7 1293 — 8y

1 answer

Log in to vote
3
Answered by
Sublimus 992 Moderation Voter
8 years ago

Connections to events are denoted with a : colon, not a . period.

Therefore, your connection line should be:

Button.MouseButton1Click:connect(onClick)

Event Triggered Functions

Ad

Answer this question