So, I made a button, then I put this into it:
01 | local function onTouch(hit) |
02 | modelOfBricks = game.Workspace.Model |
03 | nameOfBricks = "Porto" |
04 | for i,v in pairs (modelOfBricks:GetChildren()) do |
05 | if v.Name = = nameOfBricks then |
06 | v.Transparency = 0 |
07 | v.CanCollide = true |
08 | end |
09 | end |
10 | end |
11 |
12 | .Parent.Touched:connect(onTouch) |
Now I can't figure out how to make this button disappear immediately after being touched.
EDIT: Answered by rexbit, many thanks to her.
Just add a :Destroy
.
01 | local function onTouch(hit) |
02 | modelOfBricks = game.Workspace.Model |
03 | nameOfBricks = "Porto" |
04 | for i,v in pairs (modelOfBricks:GetChildren()) do |
05 | if v.Name = = nameOfBricks then |
06 | v.Transparency = 0 |
07 | v.CanCollide = true |
08 | end |
09 | end |
10 | wait() |
11 | script.Parent:Destroy() -- Once everthing has ran, just Destroy the part. |
12 | end |
13 |
14 | script.Parent.Touched:connect(onTouch) |
1 | local function onTouch(part) |
2 | if part.Parent.Name = = "Humanoid" |
3 | script.Parent:Destroy() |
4 | end |
5 |
6 | script.Parent.Touched:connect(onTouch) |
I think that work, I don't know since I can't test now, hope it helps.