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

How to make something disappear when you click a block?

Asked by 3 years ago

I've been looking for a script to where if you click a block, another block will disappear. Can anyone help me find a script or make me one that will make this happen?

2 answers

Log in to vote
0
Answered by 3 years ago

https://developer.roblox.com/en-us/api-reference/class/ClickDetector

Try to make one yourself before you ask for help.

I'd make this by checking when the click detector is fired, and then indexing the block to disappear and set it's transparency to 1.

https://developer.roblox.com/en-us/api-reference/property/BasePart/Transparency

Alternatively, I'd use Block:Destroy() to remove the block from the game, and I'd be sure to use a script instead of a localscript so it applies the change to everyone.

Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

I am a bit Mixed but I think you mean a Part / Brick?

If yeah, then here is a list of things to do.

  1. Place a Script inside the "Part you want to be the button".
  2. Place a "Click Detector" in the "Same Part".
  3. Open the Script.
  4. Use one of the codes here....

Types:

1.Destroy.

This will delete the Part you want to disappear.

local Button = script.Parent
local Target = game.Workspace."Your Target"

function onClicked()

    Target:Destroy()

end
Button.ClickDetector.MouseClick:Connect(onClicked)

2.Hide for 3 seconds or whatever time you want.

This will Hide the Part you want to disappear for 3 Seconds or whatever time you want.

local Button = script.Parent
local Target = game.Workspace."Your Target"
local CoolDown = 3

Button.ClickDetector.MaxActivationDistance = 8

function onClicked()

    Target.Transparency = 1
    Button.ClickDetector.MaxActivationDistance = 0

    wait(CoolDown)

    Target.Transparency = 0
    Button.ClickDetector.MaxActivationDistance = 8

end
Button.ClickDetector.MouseClick:Connect(onClicked)

3.Will hide the Target on Click then Unhide on click if it's hidden.

This will check if it's hidden on click if not it will hide if it is hidden it will unhide it.

local Button = script.Parent
local Target = game.Workspace."Your Target"
function onClicked()

    if Target.Transparency == 0 then

        Target.Transparency = 1

    else

        Target.Transparency = 0

    end
end
Button.ClickDetector.MouseClick:Connect(onClicked)

4.This will just hide it forever till you use a script that runs

Target.Transparency = 0

local Button = script.Parent
local Target = game.Workspace."Your Target"

function onClicked()

    Target.Transparency = 1

end
Button.ClickDetector.MouseClick:Connect(onClicked)

That's I can fit in now but if any help needed add me on discord. :D

  • Hamoodiyt#4822

I wish I helped. :)

Answer this question