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

How can I make a brick disappear by touching a different brick?

I would like to make a brick that gets removed when I touch a different brick, but I can't figure out how I can do that.

Example: We have two bricks, A and B.

When I touch A, B will get removed and won't come back.

I hope that this is all the information you need, and if not then make sure to ask and I'll try to respond as quickly as possible, any help is appreciated!

1 comment

0

this is quite simple and there are many ways to approach it but add me on discord so i know exactly how you want it set up --Donut792#1329

2 answers

✓ Accepted answer

my good sir the script that we talked about

Script:

local BrickB = workspace.BrickB
local debounce = false --added debounce so it doesnt freak out and run at 1 thousand horses a square liter
script.Parent.Touched:Connect(function(hit) -- hit defines the part that touched it
	if game.Players:FindFirstChild(hit.Parent.Name) then -- do hit.Parent because the part of the player that touched it is inside a model
 	 if debounce == false then
	    debounce = true -- make sure script cant run more than once at a time
	    local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- find teh player from the part that touched the brick
		wait(3)
		BrickB:Destroy() -- send it to the shadow realm
		debounce = false -- give the go ahead for the script to run again(its gonna be deleted anyway but good practice)
		end
	end
end)

1 comment

0

Works like I wanted it to, thanks!

Hey there! I hope i can help you!

You should use :Destroy() to remove the bricks.

Example Script(Server Script inside a part in the workspace):

local part = workspace.B

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		part:Destroy()
	else
		print("The part is not a character")
	end
end)

2 comments

0

Please mark this as the answer if this helped.

0

Hey, thanks for your answer. Unfortunately someone has already contacted me and helped me, but I tried this out and it works too.

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