{"id":25510162,"url":"https://github.com/huotchu/roblox-pubsub","last_synced_at":"2025-11-23T02:30:15.765Z","repository":{"id":40655547,"uuid":"95982000","full_name":"HuotChu/roblox-pubsub","owner":"HuotChu","description":"PubSub Module for Roblox Lua","archived":false,"fork":false,"pushed_at":"2017-08-19T21:01:44.000Z","size":10,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-03-01T08:02:36.465Z","etag":null,"topics":["roblox","robloxlua"],"latest_commit_sha":null,"homepage":"https://www.roblox.com/games/896539588/Event-Management-Demo","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HuotChu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-01T18:48:46.000Z","updated_at":"2022-06-27T10:53:15.000Z","dependencies_parsed_at":"2022-08-26T12:34:25.618Z","dependency_job_id":null,"html_url":"https://github.com/HuotChu/roblox-pubsub","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HuotChu%2Froblox-pubsub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HuotChu%2Froblox-pubsub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HuotChu%2Froblox-pubsub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HuotChu%2Froblox-pubsub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HuotChu","download_url":"https://codeload.github.com/HuotChu/roblox-pubsub/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239627247,"owners_count":19670844,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["roblox","robloxlua"],"created_at":"2025-02-19T09:14:45.584Z","updated_at":"2025-11-23T02:30:14.927Z","avatar_url":"https://github.com/HuotChu.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# roblox-pubsub\n\n### PubSub for Roblox enables 4 way code communication via an Event Management system.\n\n\n(Server/Server, Server/Client, Client/Client, Client/Server)\n\n\u0026nbsp;\n\nPubSub works with FilteringEnabled and allows for easy Publish and Subscribe functionality.\n\n\u0026nbsp;\n\nNo Copylock Sample on Roblox: https://www.roblox.com/games/896539588/Event-Management-Demo\n\nExamples and discussion on RBXDev Forums: https://devforum.roblox.com/t/pubsub-for-roblox-publish-subscribe-eventing/47850\n\n\u0026nbsp;\n\nWhy is this cool? Well, let's say I wanted to announce a player has joined the game in chat.\n\n\nThe Player joining is something we connect to on the server [Players.PlayerAdded]\n\n\nThe chat is on the client, so the server and client need a RemoteEvent to communicate through.\n\n\nYou COULD create the RemoteEvent as a static object in ReplicatedStorage, then write code on\nboth the server and the client to access that event and handle it as needed.\n\n\nOf course, you have to hope the event is there when both the client and the server are looking for it.\n\n\nYou also have to do this for every RemoteEvent in your game...\n\n\u0026nbsp;\n\n*ugh*\n\n\u0026nbsp;\n\nBetter way? PubSub.\n\n\u0026nbsp;\n\nPubSub creates RemoteEvents when they are needed and cleans them up when they aren't.\n\n\nPubSub ensures RemoteEvents are always available prior to attempted use.\n\n\nPubSub also supports client to client and server to server eventing. RemoteEvents (alone) do not.\n\n\u0026nbsp;\n\n___\n\n\u0026nbsp;\n\nLet's announce that new player in chat using PubSub:\n\n\n`ServerScriptService \u003e Script`\n\n```lua\nlocal Players = game:GetService('Players')\nlocal ReplicatedStorage = game:GetService('ReplicatedStorage')\nlocal PubSub = require(ReplicatedStorage:WaitForChild('PubSub'))\n\nlocal OnPlayerConnected = function (player)\n    wait(1)\n    PubSub.publish('AnnouncePlayer', player.Name)\nend\n\nPlayers.PlayerAdded:connect(OnPlayerConnected)\n```\n\n\n`StarterGui \u003e YourLocalScript`\n\n```lua\nlocal StarterGui = game:GetService('StarterGui')\nlocal PubSub = require(ReplicatedStorage:WaitForChild('PubSub'))\n\nPubSub.subscribe('AnnouncePlayer', function (playerName)\n\tStarterGui:SetCore('ChatMakeSystemMessage', {\n\t\tText = playerName..' joined the game!'\n\t})\nend, 'YourLocalScript')\n```\n\n\nDone. That's all there is to it.\n\n\nNo RemoteEvent objects for you to create and it is easy to use, just Publish and Subscribe!\n\n\u0026nbsp;\n\n___\n\n\u0026nbsp;\n\n### To start using PubSub in your game:\n+ Create a Module in ReplicatedStorage.\n+ Rename the module to PubSub.\n+ Copy source from the code here on GitHub in ReplicatedStorage\\PubSub.lua\n+ Paste the code into the PubSub module you made in your game and close the file.\n+ Look in the GitHub ServerScriptService\\BootStrap.lua to see more examples of use.\n\n\u0026nbsp;\n\n## THE FOLLOWING CODE FROM BOOTSTRAP.LUA IS REQUIRED IN YOUR SERVER CODE AS EARLY AS YOU CAN LOAD IT\nIf you leave this step out, the client and server will not talk to eachother!\n\n\nIf you are not sure what to do with this part, just copy the contents of BootStrap.lua\nand paste them into a Script in ServerScriptService. Do your game init or start your game\nat the end of the file after the following section has a chance to run.\n\n\n```lua\nlocal Players = game:GetService('Players')\nlocal ReplicatedStorage = game:GetService('ReplicatedStorage')\nlocal PubSub = require(ReplicatedStorage:WaitForChild('PubSub'))\n\nlocal CreateRemoteEvent = PubSub:FindFirstChild('CreateRemoteEvent')\n\nlocal onCreateRemoteEvent = function (player, t)\n    return PubSub.createEvent(t)\nend\n\nCreateRemoteEvent.OnServerInvoke = onCreateRemoteEvent\n```\n\n\u0026nbsp;\n\nOn Roblox I'm HuotChu.\n\n\nCheck out my game, Big Idea, on Roblox!\n\n\nIf PubSub helps make your game awesome, consider buying a Coffee Reward game pass :)\n#### https://www.roblox.com/games/798131599/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuotchu%2Froblox-pubsub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhuotchu%2Froblox-pubsub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuotchu%2Froblox-pubsub/lists"}