Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a brick disappear after clicking a button?

Asked by 6 years ago

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

4 answers

Log in to vote
0
Answered by
Wiscript 622 Moderation Voter
6 years ago

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.

0
Ok sorry robloxtcc570 0 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
-- 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.

0
Before the 'Wait(10)' you would need 'part.Transparancy = 1' tictac67 96 — 6y
0
They are both separate scripts, do you not see that? DeceptiveCaster 3761 — 6y
Log in to vote
0
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
6 years ago

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)
0
Kiriot, he did not specify which kind of button it was. DeceptiveCaster 3761 — 6y
0
I mean, clickdetector isn't a button, so I assumed he meant a gui button /shrug Amiaa16 3227 — 6y
0
lol DeceptiveCaster 3761 — 6y
0
could be an ImageButton too :P DeceptiveCaster 3761 — 6y
0
an ImageButton is a gui button aswell Amiaa16 3227 — 6y
Log in to vote
0
Answered by 6 years ago

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.

Answer this question