The following Developer Hub articles don’t utilise the CollectionService properly:
CollectionService/GetTagged
CollectionService/GetInstanceAddedSignal
CollectionService/GetInstanceRemovedSignal
In all of these articles, the onInstanceRemoved
function is never called - even for the documentation of GetInstanceRemovedSignal, which it is intended for.
local function onInstanceRemoved(object)
-- If we made a connection on this object, disconnect it (prevent memory leaks)
if connections[object] then
connections[object]:disconnect()
connections[object] = nil
end
end
The function is there, however it is never connected to an event. The solution would be to use the event signal this is intended to be connected to:
CollectionService:GetInstanceRemovedSignal(tag):Connect(onInstanceRemoved)