Menu button for opening and closing

So, I want this script:

local b = script.Parent.ToggleButton

local f = script.Parent.MenuFrame

local cb = script.Parent.MenuFrame.CloseButton

b.MouseButton1Click:Connect(function()

f:TweenPosition(UDim2.new(0.268, 0,0.263, 0),"Out","Quint")

end)

cb.MouseButton1Click:Connect(function()

f:TweenPosition(UDim2.new(0.26, 0,-0.9, 0),"In","Linear",0.5)

end)

to work on the “CloseButton” and with the “ToggleButton”

What I mean is that it can do “In” tween with the ToggleButton.

Basically I just want the toggle button to have the same use as the closebutton
Can somebody help?

1 Like

Whats the issue, make sure to provide more details in your post.

1 Like

Try using a Boolean variable that stores whether it is open or closed and then use if checks to tween it
e.g.

b.MouseButton1Click:Connect(function()
    if bool == true then
        [Tween]
    else
        [Tween]
    end
end)
2 Likes
local open = false

local function Open()
    if open == true then return end
    open = true
    -- tween open
end

local function Close()
    if open == false then return end
    open = false
    -- tween closed
end

local function Toggle()
    if open == false then
        Open()
    else
        Close()
    end
end
1 Like

You don’t even need a boolean value, rather just check if the position is in the closed or open positions.

1 Like