If you set a parent of an object to NIL can you get it back

im trying to set a UI frame to nil for storage at a NIL parent

example:

local getPartBack = script.Event
local part = script.Frame
part.Parent = nil

wait(5)
getPartBack:Fire()

getPartBack.Event:Connect(function()
    part.Parent = script.Parent.Parent.Workspace
end)

will the part be deleted when parenting to NIL or will the script still have a reference to the object to parent it back into reality?

Parts are not deleted when their parent is set to nil so if the reference exists in scope it’d be fine

1 Like

In fact, you should never use assigning an object’s parent as nil to try and “destroy” an item as it does not guarantee that the item is destroyed
see the following reference page
https://create.roblox.com/docs/reference/engine/classes/Instance#Destroy

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.