This SurfaceGui makes a part when clicked. How do I make the part disappear when I click the Surface Gui again?
local Surface = Instance.new("SurfaceGui", script.Parent)
Surface.Adornee = script.Parent
local frame = Instance.new("Frame", Surface)
frame.Size = UDim2.new(.8, 160, 1, 160)
frame.Transparency = 1
local Button = Instance.new("TextButton",frame)
Button.Size = UDim2.new(.8, 160, 0.58, 160)
Button.BackgroundColor3 = BrickColor.White().Color
Button.Text = "Brick Creator"
Button.TextScaled = true
Button.MouseButton1Down:connect(function()
local brick Instance.new("Part", game.Workspace)
end)

6 comments
It crashes my game...
It works fine for me.
Edited to show exactly what I tested.
Nevermind. It's because I didn't name it.
Nice. Glad it worked out!
Instead of using game.Workspace:findFirstChild("DeletionTarget"), you just make the brick created be destroyed.