So, I made a button, then I put this into it:
local function onTouch(hit) modelOfBricks = game.Workspace.Model nameOfBricks = "Porto" for i,v in pairs(modelOfBricks:GetChildren()) do if v.Name == nameOfBricks then v.Transparency = 0 v.CanCollide = true end end end .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
.
local function onTouch(hit) modelOfBricks = game.Workspace.Model nameOfBricks = "Porto" for i,v in pairs(modelOfBricks:GetChildren()) do if v.Name == nameOfBricks then v.Transparency = 0 v.CanCollide = true end end wait() script.Parent:Destroy() -- Once everthing has ran, just Destroy the part. end script.Parent.Touched:connect(onTouch)
local function onTouch(part) if part.Parent.Name == "Humanoid" script.Parent:Destroy() end script.Parent.Touched:connect(onTouch)
I think that work, I don't know since I can't test now, hope it helps.