Skip to content

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.

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.

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-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)

Use :Connect() to listen for incoming packets.

Network.Server.OpenRewardMenu:Connect(function(data)
print(data.rewardId)
end)