With the release of the new MessagingService, some people may not know how to work it exactly. I came up with the idea of making it into a simple OOP last night and wanted to make it real.
Documentation is pretty simplistic.
local Handler = require(script.ModuleScript)
local Service = Handler.Attach('Test') --Attaches and listens to given topic
Service.OnData:Connect(function(Content,Timestamp) --When the attached topic is being published to
print('[HANDLER DATA]')
print(Content,' | ',Timestamp)
end)
Service.Publish('hello there')
Service:Disconnect()
--after disconnect, if you try to publish to it again it will error
wait(1)
Service.Publish('hello there!!')
Hope this helps people that need it!