Enabling and disabling a part

  1. What do you want to achieve? Enable and disable a part.

  2. What is the issue? I can remove the part, but can’t recover it to its original state.

  3. **What solutions have you tried so far?**Tried declaring it nil then declaring it back to its parent

1 Like

You could clone it before you delete it.

Actually, you could just parent the part to nil.

local part = workspace.Part
wait(2)
local oldParent = part.Parent
part.Parent = nil -- "disable"
wait(2)
part.Parent = oldParent -- "enable"

If you plan on doing this with many parts, very often, you may want to look into solutions like PartCache.

1 Like

Not entirely sure what you mean, but maybe try setting the Transparency to 1 and CanCollide to false.

There is not, “Enabled” option for a part.
You can try change the cancollide and transparency state to make it look like the part is disappearing and reappearing.
If you would like to completely remove it from the game, you can use the :Destroy() and :Clone().

local Part = script.Part
local PartPosition = Vector3.new(0,0,0)
-- Event1 --
Part:Destroy()
-- Event2 --
local ClonePart = Instance.new("Part")
ClonePart.Parent = script
ClonePart.Position = PartPosition
ClonePart.Anchored = true

You can also use Clone(). If this does not the answer you are looking for, could you please explain again?

There are a few ways you can do this, as others have suggested.

  1. Transparency & CanCollide
local Part = script.Parent

Part.Transparency,Part.CanCollide = 1,false
Part.Transparency,Part.CanCollide = 0,true -- To bring it back
  1. Set its parent to nil
local Part = script.Parent

Part.Parent = nil
Part.Parent = workspace -- To bring it back
  1. Clone & destory original
local Part = script.Parent

local Clone = Part:Clone()
Clone.Parent,Clone.Transparency,Clone.CanCollide = workspace,1,false
Clone.Position = Part.Position
Part:Destory() -- Destroy original part

Clone.Transparency,Clone.CanCollide = 0,true -- To bring it back

Edit: I meant to reply to the OP lol

Yeah I was thinking of that yesterday, I’ll see