replica:AddCleanupTask(task: (() -> ()) | { Destroy: (any) -> () }): void
Server & ClientRegisters a task (function or Destroy-able object) to run automatically when the Replica is destroyed.
Parameters
task*(() -> ()) | { Destroy: (any) -> () } | A plain function or any object exposing a Destroy method. |
Returns
voidNo return value.
replica:AddCleanupTask(function()
print("Cleaning up resources tied to", replica.Token)
end)