-- Compiled with roblox-ts v3.0.0 local TS = _G[script] local Players = TS.import(script, TS.getModule(script, "@rbxts", "services")).Players local InstanceTools = TS.import(script, script.Parent, "instance_tools").InstanceTools local NetworkingTools = {} do local _container = NetworkingTools local function FireAllClientsExcept(remote_event, exceptions, ...) local args = { ... } local players = Players:GetPlayers() -- ▼ ReadonlyArray.forEach ▼ local _callback = function(player) local _exceptions = exceptions local _player = player if table.find(_exceptions, _player) ~= nil then return nil end remote_event:FireClient(player, unpack(args)) end for _k, _v in players do _callback(_v, _k - 1, players) end -- ▲ ReadonlyArray.forEach ▲ end _container.FireAllClientsExcept = FireAllClientsExcept --*always returns true local function AlwaysTrue() return true end --[[ * * sends the data from one client directly to others * sends the player who sent request and the arguments * @param remote_event remote event that is going to be broadcasted to other clients * @param check_arguments_callback checks if the client sends the valid information ]] local function ResendToClientsConnection(remote_event, check_arguments_callback) if check_arguments_callback == nil then check_arguments_callback = AlwaysTrue end --takes the arguments from the remote event and fires to all clients except of him return remote_event.OnServerEvent:Connect(function(player, ...) local args = { ... } --if didnt pass the check, dont send to other clients if not check_arguments_callback(unpack(args)) then return nil end FireAllClientsExcept(remote_event, { player }, player, unpack(args)) end) end _container.ResendToClientsConnection = ResendToClientsConnection local function GetOrCreateNetworkFolder() local folder_name = "network__" return InstanceTools.GetOrCreate(folder_name, script, "Folder", {}) end --[[ * * creates the remote event for server and client, has to be executed from both sides * @param name name of remote event * @param parent parent where the remote event is located * @returns remote event ]] local function DefineRemoteEvent(name, parent, unreliable) if parent == nil then parent = GetOrCreateNetworkFolder() end return InstanceTools.DefineItem(name, parent, if unreliable then "UnreliableRemoteEvent" else "RemoteEvent", {}) end _container.DefineRemoteEvent = DefineRemoteEvent local function DefineRemoteFunction(name, parent) if parent == nil then parent = GetOrCreateNetworkFolder() end return InstanceTools.DefineItem(name, parent, "RemoteFunction", {}) end _container.DefineRemoteFunction = DefineRemoteFunction end return { NetworkingTools = NetworkingTools, }