To make a button be able to make something both visible and invisible, you’ll just have to change your MouseButton1Click function slightly.
Frame = script.Parent.Parent.Frame
script.Parent.MouseButton1Click:Connect(function()
Frame.Visible = not Frame.Visible
end)
And as @SelDraken said, do not have the button parented to the frame if youre going to change its visibility.
This will cause the button to become invisible when changing the frames visibility:
This will not cause the button to become invisible when changing the frames visibility:
The script i supplied does make the same button open and close it.
The whole reason i did not Frame.Visible is because it inverts the BoolValue of the Visible property.
So if Frame.Visible == true then it will make it false, and if Frame.Visible == false then it will make it true.
local Frame = game.StarterGui.ScreenGui.Frame.Visible
if Frame == true then
script.Parent.MouseButton1Click:Connect(function()
Frame = false
end)
end
if Frame == false then
script.Parent.MouseButton1Click:Connect(function()
Frame = true
end)
end
-- Im assuming that the button is parented to the same ScreenGui
-- If it isnt, make it parented to the same ScreenGui, NOT THE SAME FRAME.
local Frame = script.Parent.Frame
script.Parent.MouseButton1Click:Connect(function()
Frame.Visible = not Frame.Visible
end
Yes, that would work. just parent the script to the ScreenGui itself, and not the button.
And then instead of doing script.Parent.MouseButton1Click ,
do Script.Parent.account_box.MouseButton1Click
local Frame = game.StarterGui.ScreenGui.Frame.Visible
script.Parent.MouseButton1Click:Connect(function()
if Frame.Visible == true then
Frame.Visible = false
else
Frame.Visible = true
end
end)