-
-
Save dphfox/59714ae885a2a0b4d1d1c01f3dcb449f to your computer and use it in GitHub Desktop.
Roblox GC issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function new() | |
local ref = {instance = Instance.new("TextButton")} | |
ref.instance.Parent = workspace | |
local function updateRefStrength() | |
if game:IsAncestorOf(ref.instance) then | |
setmetatable(ref, {}) | |
else | |
setmetatable(ref, {__mode = "v"}) | |
end | |
end | |
task.defer(updateRefStrength) | |
ref.instance.AncestryChanged:Connect(updateRefStrength) | |
ref.instance.Activated:Connect(function() | |
print(ref.instance.Name) | |
end) | |
return ref.instance | |
end | |
local ref = setmetatable({new()}, {__mode = "v"}) | |
delay(5, function() | |
print("moving to nil!") | |
ref[1].Parent = nil | |
end) | |
while ref[1] do | |
print("still alive...") | |
wait(1) | |
end | |
print("gone!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment