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

How do i make a block dissapear after its been clicked?

I've tried stuff like Game.Workspace stuff, and Parent. stuff, and I can seem to get it. any help?

2 answers

lol ok

place in part:

local part = script.Parent
local clickD = Instance.new("ClickDetector", part)

clickD.MouseClick:Connect(function()
	part:Destroy()
end)

this will spawn a clickdetector in the part, which detects clicks. Im using a clickdetector as it is a much easier to use and more viable option instead of say, without it.

I'll write this in a simple way, so you understand it.

Put a script inside the part and delete everything in it.

First, we make a function called Click

function Click()

end

Now, we make it so Click is called when the part is clicked.

Assuming you have a ClickDetector inside the part called "ClickDetector", we do this:

script.Parent.ClickDetector.MouseClick:Connect()

Lastly, we make the block become invisible. To do so, we put the line inside the "Click" function

function Click()
script.Parent.Transparency = 1 --Makes the block invisible.
end

if you put the following line right in middle of the invisibility line and the end, you can also make it so players can walk through the brick:

script.Parent.CanCollide = false

If for some reason you don't know how to put a clickdetector, put this line above everything in the script.

local CD = Instance.new("ClickDetector")
CD.Parent = script.Parent

And please, next time read the wiki or look for youtube tutorials. This site is for more complex things.

You're welcome.

This discussion is preserved as it was. New answers, comments, and votes are closed.