Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make a brick disappear after clicking a button?

I want to make a brick disappear in 10 seconds after clicking a button. How to do that?

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.

1 comment

0

Ok sorry

-- 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

0

Before the 'Wait(10)' you would need 'part.Transparancy = 1'

0

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

0

Kiriot, he did not specify which kind of button it was.

0

I mean, clickdetector isn't a button, so I assumed he meant a gui button /shrug

0

lol

0

could be an ImageButton too :P

0

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.