Do object references in destroyed scripts cause memory leaks?

For instance, if I had a Server Script that contained:

local variable = workspace:FindFirstChild("Model")

If it’s not nil, and something else runs

workspace.Script:Destroy()

Will this cause a memory leak? If it does, how can I avoid this?

Once a script is destroyed, any references you’ve written in the destroyed script are no longer accessible. So therefor, this should be cleaned up by Roblox’s garbage collector automatically.

2 Likes