I want to make a brick disappear in 10 seconds after clicking a button. How to do that?
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.
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)
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.