Creating Packet Events
This page goes on a pretty vague explaination. For more in-depth information (Such as Event Directions) you can check out the other pages.
Packet Events are one-way communication packets that allow the server and client to send data without expecting a response.
Unlike Packet Functions, Packet Events do not return a value. They are useful for actions such as opening UI, updating state, or notifying another side about something that happened.
Creating a Packet Event
Section titled “Creating a Packet Event”Packet Events are created inside a network schema using Packeteer.event().
local Packeteer = require(path.to.Packeteer)
return Packeteer.create({ Server = { OpenRewardMenu = Packeteer.event<<{ rewardId: number }>>(), },
Client = { EquipItem = Packeteer.event<<{ itemId: string }>>(), },})The location of the event determines which side owns the packet:
- Server packets are used for server -> client communication.
- Client packets are used for client -> server communication.
Firing Events
Section titled “Firing Events”Server Events
Section titled “Server Events”Server-owned packets must be fired from the server.
Network.Server.OpenRewardMenu:Fire(player, { rewardId = 123})Then the client can listen for this event:
Network.Server.OpenRewardMenu:Connect(function(data) print(data.rewardId)end)Client Events
Section titled “Client Events”Client-owned events are fired from the client.
Network.Client.EquipItem:Fire(nil, {itemId = "Sword"})Then the server can listen for this event:
Network.Client.EquipItem:Connect(function(player, data) print(player.Name, data.itemId)end)Connecting Events
Section titled “Connecting Events”Use :Connect() to listen for incoming packets.
Network.Server.OpenRewardMenu:Connect(function(data) print(data.rewardId)end)