NetWire
NetWire is a networking library that enables functionality similar to Sleitnick's Comm library, except it doesn't require the usage of intermediate instances.
Basic usage:
-- SERVER
local NetWire = require(Packages.NetWire)
local myWire = NetWire("MyNetWire")
myWire.MyEvent = NetWire.createEvent()
myWire.MyEvent:Connect(function(plr: Player, msg: string)
print(plr, "said:", msg)
end)
-- CLIENT
local NetWire = require(Packages.NetWire)
local myWire = NetWire("MyNetWire")
myWire.MyEvent:FireAll("Hello, world!")
Properties
Client
This item only works when running on the client. ClientNetWire.Client:
ClientNetWire
Server
This item only works when running on the server. ServerNetWire.Server:
ServerNetWire
Functions
createEvent
This item only works when running on the server. ServerReturns an EventMarker that is used to mark where a remoteSignal should be created. Calls ServerNetWire:RegisterEvent() when set to the index of a ServerNetWire. See ServerNetWire:RegisterEvent for more information.
local MyWire = NetWire.Server("MyWire")
MyWire.MyEvent = NetWire.createEvent()
MyWire.MyEvent:Connect(function(plr: Player, msg: string)
print(plr, "said:", msg)
end)
createUnreliableEvent
This item only works when running on the server. ServerReturns an EventMarker that is used to mark where a remoteSignal should be created. Calls ServerNetWire:RegisterEvent() when set to the index of a ServerNetWire. See ServerNetWire:RegisterEvent for more information.
local MyWire = NetWire.Server("MyWire")
MyWire.MyEvent = NetWire.createUnreliableEvent()
MyWire.MyEvent:FireAll("Hello, world!")
createProperty
This item only works when running on the server. ServerReturns an PropertyMarker that is used to mark where a remoteProperty should be created. Calls ServerNetWire:RegisterProperty() when set to the index of a ServerNetWire. See ServerNetWire:RegisterProperty for more information.
local MyWire = NetWire.Server("MyWire")
MyWire.MyProperty = NetWire.createProperty(0)
print(MyWire.MyProperty:Get()) -- 0