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

Make a block that appears when another block is pressed?

Asked by 4 years ago

I am working on a game, and I wanted to make a block that appears when another block is pressed. Does anyone know a script I can use for this?

0
This site is for getting help with writing scripts, not requesting scripts. blazar04 281 — 4y
0
elaborate on 'pressed'. Like clicked or touched? Subsz 366 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Since you provided a such roughly question, I will help the code while explaining to you.

1.Define two bricks.

local BrickDisappear = workspace.PartA
local BrickTouch = workspace.PartB

The codes above defines two bricks.

2.Set up the signal(event) listener.

local Signal = nil
Signal = BrickTouch.Touched:Connect(function()
    BrickDisappear.Transparency = 1
    Signal:Disconnect()
    Signal = nil
end)

Since the Touched signal should only be listened once, we disconnect it after it fires.

3.Put all together.

local BrickDisappear = workspace.PartA
local BrickTouch = workspace.PartB
local Signal = nil
Signal = BrickTouch.Touched:Connect(function(part)
    BrickDisappear.Transparency = 1
    Signal:Disconnect()
    Signal = nil
end)

Documentation:

BasePart.Touched

BasePart.Transparency

Ad

Answer this question