Firing Packet Events
Firing a Packet Event sends data from the owner of the packet to the opposite side.
The way an event is fired depends on whether the packet is server-owned or client-owned.
Firing Server-Owned Events
Section titled “Firing Server-Owned Events”Server-owned events are fired from the server and received by the client.
Example schema:
Server = { OpenRewardMenu = Packeteer.event<<{ rewardId: number }>>(),}To fire a server-owned event, use :Fire() from the server:
Network.Server.OpenRewardMenu:Fire(player, { rewardId = 123})The first argument is the recipient of the event.
You can send an event to a single player:
Network.Server.OpenRewardMenu:Fire(player, { rewardId = 123})Or multiple players:
-- Using Players:GetPlayers()Network.Server.OpenRewardMenu:Fire(Players:GetPlayers(), { rewardId = 123})
-- Using a tableNetwork.Server.OpenRewardMenu:Fire({ player1, player2 }, { rewardId = 123})The receiving client will only receive the event data:
Network.Server.OpenRewardMenu:Connect(function(data) print(data.rewardId)end)Firing Client-Owned Events
Section titled “Firing Client-Owned Events”Client-owned events are fired from the client and received by the server.
Example schema:
Client = { EquipItem = Packeteer.event<<{ itemId: string }>>(),}To fire a client-owned event, use :Fire() from the client:
Network.Client.EquipItem:Fire(nil, { itemId = "Sword"})The server receives the player who fired the event automatically:
Network.Client.EquipItem:Connect(function(player, data) print(player.Name) print(data.itemId)end)