Ad
Log in to vote
0

Close button

Asked by 7 years ago

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

4 answers

Log in to vote
2
Answered by 7 years ago

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

Ad
Log in to vote
1
Answered by 7 years ago

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.

Log in to vote
0
Answered by 7 years ago

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!

Log in to vote
0
Answered by 8 months ago

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.

Answer this question