A script with a loop that is set to nil will run forever or it will be gc’ted over time?
As I understand from reading posts, other instances as parts will be, but scripts wont.
Is there a way to get a table of anything which is parented to nil?
A script with a loop that is set to nil will run forever or it will be gc’ted over time?
As I understand from reading posts, other instances as parts will be, but scripts wont.
Is there a way to get a table of anything which is parented to nil?
Anything parented to nil will continue existing just not accessible to the explorer, such is an example:
local Brick = workspace.Part
Brick.Parent = nil
workspace.Part:Destroy() -- Will return error
Brick:Destroy() -- Will actually delete the brick from the game session
This is because the part has already been referenced by the script which therefore knows the instance’s current properties like parent.
According to the official documentation the script will continue to run. And if the loop is infinite, then forever.
A script will continue to run even if the Parent property is set to nil (and the Script is not destroyed).
It is not possible to get reference to instances that have been parented to nil. An Instance must always be in the game tree or be referenced by a variable (or in table), otherwise it becomes a memory leak (unless that is your intention).
A script with a loop that is set to nil will run forever or it will be gc’ted over time?
You can run whatever code you want regardless if the parent is set to nil or not.
Is there a way to get a table of anything which is parented to nil?
Yes, but you need a reference to it first.