I need some help

Can someone please tell me what I would need to do for this:

I want to make a button, and when you click it it makes a part disappear. When you click the button again, the part appears again.

I’m using this to make the roof of a building appear and disappear when you click the button.

I would greatly appreciate it if someone walked me through how I would make this because i’m a new developer, thank you! :slight_smile:

1 Like

You can use transparency to make it disappear without making it delete.
Transparency Example:

Part = script.Parent.Part
local clickdetector = script.Parent:WaitForChild("ClickDetector")

clickdetector.MouseClick:Connect(function()

if Part.Transparency == 0 then
Part.Transparency = 1
elseif Part.Transparency == 1 then
Part.Transparency = 0

end)

The script is messy but that’s how I would do it.

4 Likes

You can use ClickDetector to do this, here’s a sample.

local Part = script.Parent --The part is the parent of the script right here, you can edit this variable to any part you want.

-- Create a ClickDetector in the Part
local ClickDetector = Instance.new("ClickDetector")
ClickDetector.Parent = Part

ClickDetector.MouseClick:Connect(function()

if Part.Transparency == 0 then
	Part.Transparency = 1
else -- You can also use elseif if you want, but you don't have to in this case.
	Part.Transparency = 0
end

end)
1 Like