I want to make a brick disappear in 10 seconds after clicking a button. How to do that?
How to make a brick disappear after clicking a button?
4 answers
It depends what type of button Also, this isn't a request site. Please check out this awesome thread on how to post a good question.
Please don't hesitate in posting a new, more descriptive question.
-- ClickDetector
part = script.Parent
part.ClickDetector.MouseClick:Connect(function()
wait(10)
part.Transparency = 1
end)
-- GUI Button (TextButton or ImageButton)
gui = script.Parent
gui.MouseButton1Down:Connect(function()
wait(10)
game.Workspace.Target.Transparency = 1 -- Target part
end)
Pick either one you like.
2 comments
Before the 'Wait(10)' you would need 'part.Transparancy = 1'
They are both separate scripts, do you not see that?
Connect a MouseButton1Click event to the button, then use the Destroy() function of the part after waiting 10 seconds, like so:
local button = script.Parent --replace
local brick = workspace.Brick --replace
button.MouseButton1Click:Connect(function()
wait(10)
brick:Destroy()
end)
Or use the Debris service:
local button = script.Parent --replace
local brick = workspace.Brick --replace
button.MouseButton1Click:Connect(function()
game:GetService("Debris"):AddItem(brick, 10)
end)
5 comments
Kiriot, he did not specify which kind of button it was.
I mean, clickdetector isn't a button, so I assumed he meant a gui button /shrug
lol
could be an ImageButton too :P
an ImageButton is a gui button aswell
Put this script inside the part you want to be clicked.
local button = script.Parent
local brick = game.Workspace.brick
button.MouseButton1Click:connect(function()
brick:Destroy()
end
Or if you wanted the button to be touched by another object and destroy the brick, replace MouseButton1Click with Touched.
I am a beginner so... I hope this helped.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Ok sorry