So I’m working on custom events similar to Roblox’s ones, and the biggest issue I have right now is thinking about how to make the events shared between the client and the server.
This is the logic I’m using with the events.
local connectionClass = require(...)
local eventClass = {}
eventClass.__index = eventClass
function eventClass:Connect(functionToConnect)
local connection = connectionClass.new(functionToConnect)
self.connections[#self.connections+1] = connection
end
function eventClass:Fire()
for i = 1,#self.connections do
local v = self.connections[i]
v()
end
end
return {
new = function()
self = setmetatable({}, eventClass)
self.connections = {}
return self
end
}