0

# Close button

I have a close button but when I press it ,it removes the text instead of the whole thing. Anyone know whats wrong?Thanks

2

It could be what Owen said. Also, if the text object is in a Frame, don't forget to delete the Frame rather than the text object, otherwise an empty Frame will remain

1

The only way that the button would do this is the fact that you are editing the text property instead of removing the GuiObject, example:

local Button = script.Parent

Button.MouseButton1Down:connect(function()
Button.Text = "" -- This is how you must be doing it to clear the text, if the text is a label you've got the amount of Parents incorrect.
end)

-- This is how it should be done:
Button.MouseButton1Down:connect(function()
Button:Destroy()
end)


Hope this helped solve your problem.

0

You could also set the Visible property on the frame to false, so you can open it later if you want.

local Close = script.Parent

Function onClick()
Close.Parent.Visible = false --Make the frame invisible
--Close.Visible = false <== Use that if you just want the button to disappear
--Open.Visible = true So you don't have a open and close button at the same time
end
Close.MouseButton1Down:connect(onClick)


If you want an open button, you could just do this:

local Open = script.Parent
local Frame = Open.Parent.Parent.Frame --Whatever you want to open
Function onClick()
Frame.Visible = true --Make the frame visible again
--Frame.Close.Visible = true <== To only make the button appear
Open.Visible = false --So you don't have an open and close button at the same time
end
Open.MouseButton1Down:connect(onClick)


Hope this helps!