25 lines
1.0 KiB
Luau
25 lines
1.0 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 = {}
|
|
|
|
function Events.new(members: () -> {Player}): Types.Events
|
|
return {fire = function(kind, payload, audience)
|
|
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
|