#Need a part to dissapear when clicked

13 messages · Page 1 of 1 (latest)

dusk falcon
#

i can do it

#

local part = script.Parent

part.Touched:Connect(function(hit)
if hit:IsA("BasePart") then
part:Destroy()
end
end)

severe orchid
dusk falcon
dusk falcon
# severe orchid i need it to re appear when re clicker

local part = script.Parent
local isHidden = false
local originalPosition = part.Position

local function toggleVisibility()
if isHidden then
part.Position = originalPosition
part.Transparency = 0
isHidden = false
else
part.Position = Vector3.new(0, -1000, 0)
part.Transparency = 1
isHidden = true
end
end

part.Touched:Connect(function(hit)
if hit:IsA("BasePart") then
toggleVisibility()
end
end)

severe orchid
#

ty

dusk falcon
digital nimbus
#

that's a pretty bad way of doing it, here's a better version:

local ServerStorage = game:GetService("ServerStorage")

-- Make sure you create a folder in ServerStorage
-- with this exact name!
local HiddenParts = ServerStorage:FindFirstChild("HiddenParts")
local Part = script.Parent

local Hidden = false
local OldParent = Part.Parent

local function TogglePart(): ()
  Hidden = not Hidden
  Part.Parent = if Hidden then HiddenParts else OldParent
end

-- `BasePart#Touched` only works on `BasePart`s
Part.Touched:Connect(TogglePart)
#

@dusk falcon @severe orchid

#

Also that's not gonna make it disappear on click but if his script worked, this also should (but better)

#

If you want it to disappear on click and without the ability to appear again then use a ClickDetector:

local Part = script.Parent
local ClickDetector = Part:FindFirstChildOfClass("ClickDetector")

-- You can also see the player who clicked by adding
-- an argument to the function
ClickDetector.MouseClick:Connect(function()
  Part:Destroy()
end)
digital nimbus