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

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

Asked by 5 years ago

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!

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 Donut792 216 — 5y

2 answers

Log in to vote
0
Answered by
Donut792 216 Moderation Voter
5 years ago

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)
0
Works like I wanted it to, thanks! oliwierpl11alt 20 — 5y
Ad
Log in to vote
0
Answered by
BashGuy10 384 Moderation Voter
5 years ago
Edited 5 years ago

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)
0
Please mark this as the answer if this helped. BashGuy10 384 — 5y
0
Hey, thanks for your answer. Unfortunately someone has already contacted me and helped me, but I tried this out and it works too. oliwierpl11alt 20 — 5y

Answer this question