Files

27 lines
1.1 KiB
Luau

--!strict
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local Types = require(script.Parent.Types)
local existing = ReplicatedStorage:FindFirstChild("ArenaObjectiveEvent")
local remote = if existing and existing:IsA("RemoteEvent") then existing else Instance.new("RemoteEvent")
remote.Name = "ArenaObjectiveEvent"
remote.Parent = ReplicatedStorage
local Events = {}
local Diagnostics = require(script.Parent.ZoneDiagnostics)
function Events.new(members: () -> {Player}): Types.Events
return {fire = function(kind, payload, audience)
Diagnostics.event()
local packet = table.clone(payload or {}) :: {[string]: any}
packet.t = workspace:GetServerTimeNow()
for _, player in members() do
if player.Parent ~= Players then continue end
local side = player:GetAttribute("ArenaTeam")
local want = audience == nil or audience == "All" or audience == side
if not want and typeof(audience) == "table" then want = table.find(audience, player) ~= nil end
if want then remote:FireClient(player, kind, packet) end
end
end}
end
return Events