--!strict local ReplicatedStorage = game:GetService("ReplicatedStorage") local remote = ReplicatedStorage:WaitForChild("ArenaObjectiveEvent") :: RemoteEvent type Handler = (any) -> () local handlers: {[string]: {Handler}} = {} local Router = {} function Router.on(kind: string, handler: Handler): () -> () local list = handlers[kind] or {} handlers[kind] = list table.insert(list, handler) return function() local index = table.find(list, handler) if index then table.remove(list, index) end end end remote.OnClientEvent:Connect(function(kind: string, payload: any) if typeof(payload) ~= "table" then return end for _, handler in table.clone(handlers[kind] or {}) do task.spawn(handler, payload) end end) return Router