PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience

Memory Management: Code Sample 2

Memory Management: Code Sample 2

Oct 01 2018, 3:14 AM PST

local descendants = {}

local function onDescendantAdded(descendant)
	descendants[descendant] = true
end

local function onDescendantRemoving(descendant)
	if descendants[descendant] then
		descendants[descendant] = nil
	end
end

workspace.DescendantAdded:Connect(onDescendantAdded)
workspace.DescendantRemoving:Connect(onDescendantRemoving)