I have a close button but when I press it ,it removes the text instead of the whole thing. Anyone know whats wrong?Thanks
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
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.
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!
I'm not entirely sure what you mean. Correct me if I'm wrong, but from what you've said, I believed you were saying that when you press a button, only the text is destroyed, and not the entire ScreenGui. If that is the problem, reply to me ASAP.