{"id":17457808,"url":"https://github.com/iconmaster5326/rbxrpc","last_synced_at":"2025-04-09T17:38:31.210Z","repository":{"id":72130294,"uuid":"86022268","full_name":"iconmaster5326/RbxRPC","owner":"iconmaster5326","description":"A ROBLOX tool to manage your RemoteEvents, so you don't have to.","archived":false,"fork":false,"pushed_at":"2017-10-10T18:46:34.000Z","size":20,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T19:44:32.088Z","etag":null,"topics":["lua","roblox","robloxlua"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iconmaster5326.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-24T03:14:44.000Z","updated_at":"2024-05-20T02:21:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"ddb3f87b-4eff-4e4c-9cda-3bdc5d6a2b0c","html_url":"https://github.com/iconmaster5326/RbxRPC","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iconmaster5326%2FRbxRPC","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iconmaster5326%2FRbxRPC/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iconmaster5326%2FRbxRPC/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iconmaster5326%2FRbxRPC/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iconmaster5326","download_url":"https://codeload.github.com/iconmaster5326/RbxRPC/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248078352,"owners_count":21044094,"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":["lua","roblox","robloxlua"],"created_at":"2024-10-18T03:06:22.384Z","updated_at":"2025-04-09T17:38:31.187Z","avatar_url":"https://github.com/iconmaster5326.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Roblox RPC (RbxRPC)\n\n## In Short\n\nRbxRPC is a library that makes and calls RemoteEvents automatically, so you don't have to.\n\n## In Long\n\nRbxRPC is an API for the easy contruction of remote procedure calls (RPCs); that is, make\nfunctions cross the client/server boundary without the end user needing to make the transmissions of\ndata themselves. In ROBLOX, data can be transmitted through RemoteFunction objects; RbxRPC allows you\nto automatically generate versions of your codebase that use RemoteFunctions when they need to cross\nthe client-server boundary, without creating a single RemoteFunction yourself.\n\n## How To Install\n\nIn ROBLOX Studio, import RbxRPC.lua as a ModuleScript into your ReplicatedStorage. That's it!\n\n## How To Use\n\nThis ModuleScript exposes two functions, getClientApi and getServerApi. They both take one argument,\napiFunc, which is a function that must return a table. It will call this function, passing in one\nparameter, which is the table that is about to be populated with the translated API. The table\nreturned by apiFunc is a map, with string keys and values as follows:\n\n* \"name\" - A unique identifier for the API you're making.\n* \"client\" - A table, like the kind you would return from a ModuleScript, of client-side functions.\n* \"server\" - A table, like the kind you would return from a ModuleScript, of server-side functions. Note that you are passed in an extra argument in the front, which is the client who called the function, or nil if it was called from the server.\n* \"common\" - A table, like the kind you would return from a ModuleScript, of functions that do not need to be handled specially by RbxRPC.\n* \"clientOnly\" - Like \"client\", but these functions cannot be called by the server at all.\n* \"serverOnly\" - Like \"server\", but these functions cannot be called by clients at all. They do not take an extra argument like normal server functions do.\n\nAll of these fields are optional. Note that the client, server, and common tables can have sub-tables; they will be merged together\nas you would expect.\n\ngetClientApi returns the API, merged together, that should be used only by clients. getServerApi does\nthe same thing for the server-side code. So now, after calling the correct get*Api function, you can\ncall functions from both the client and server side without issue.\n\nWhy does apiFunc get passed in a parameter? This allows you to call other functions in your API\nwhile taking advantage of RbxRPC. In your apiFunc, ALWAYS index the parameter to call other\nfunctions in your API, and NEVER call them through the tables you're about to return!\n\n## Tutorial\n\nHere is a template for you to easily make your own APIs with.\n\n### The Common Module\n\nFirst, create a ModuleScript in ReplicatedStorage. This will be the single place for your entire API:\n\n```lua\nreturn function(api)\n\tlocal client = {}\n\tlocal server = {}\n\tlocal common = {}\n\t\n\t-- \u003cyour functions here\u003e\n\t\n\treturn {\n\t\tname = \"\u003cyour api's name\u003e\",\n\t\tclient = client,\n\t\tserver = server, \n\t\tcommon = common,\n\t}\nend\n```\n\nIt's good practice to give \"name\" the same name as the ModuleScript you create it in.\n\nThis template gives you 3 tables to add functions to: client, server and common. To add a function to one of the tables, make something like this:\n\n```lua\nfunction client.clientFunctionName(...)\n\treturn game.Players.LocalPlayer\nend\n\nfunction server.serverFunctionName(calledFrom, ...)\n\treturn game.ServerStorage\nend\n\nfunction common.commonFunctionName(...)\n\treturn 42\nend\n```\n\nNote that server-side functions are special: They get one extra argument, which is the player that called it, or nil if it was from the server. When you yourself call this function, you will not need to provide this argument.\n\nYou can have sub-tables, just like any other ModuleScript you've made before:\n\n```lua\nclient.subTable = {}\nserver.subTable = {}\n\nfunction client.subTable.clientFunctionName(...)\n\treturn game.Players.LocalPlayer\nend\n\nfunction server.subTable.serverFunctionName(calledFrom, ...)\n\treturn game.ServerStorage\nend\n```\n\nThese tables will get merged together at some point, so make sure you NEVER define two functions with the same name and location, like this:\n\n```lua\n-- DO NOT DO THIS\nfunction client.sameName(...)\n\treturn game.Players.LocalPlayer\nend\n\nfunction server.sameName(calledFrom, ...)\n\treturn game.ServerStorage\nend\n-- DO NOT DO THIS\n```\n\nNow, you might be wondering what the parameter 'api' is for. Put simply, it is the table that will hold the finished result of RbxRPC's operations. All you need to know is that, when you want to call another function in the API, use that parameter:\n\n```lua\nfunction server.foo(calledFrom, x)\n\treturn x+1\nend\n\nfunction client.rightWay(x)\n\treturn api.foo(x/2) -- works fine, calling the version on the client\nend\n\nfunction client.wrongWay(x)\n\treturn client.foo(x/2) -- THIS WILL BREAK, DO NOT DO\nend\n```\n\n### Importing The Module\n\nOkay, so your module of functions is written. How to import it into scripts that need it? This line will do it for server-side Scripts:\n\n```lua\nlocal yourApi = require(game.ReplicatedStorage.RbxRPC).getServerApi(require(game.ReplicatedStorage.\u003cyour ModuleScript name\u003e)))\n```\n\nand this line will do it for client-side LocalScripts:\n\n```lua\nlocal yourApi = require(game.ReplicatedStorage:WaitForChild(\"RbxRPC\")).getClientApi(require(game.ReplicatedStorage:WaitForChild(\"\u003cyour ModuleScript name\u003e\")))\n```\n\nRename `yourApi` to whatever you want, of course.\n\n### Using The Module\n\nNow, you can use the table returned to call whatever you defined in your ModuleScript:\n\n```lua\n-- from the server:\n\nyourApi.serverFunctionName(1, 2, 3)\nyourApi.clientFunctionName(game.Players:GetChildren()[1], 1, 2, 3)\n\n-- from the client:\n\nyourApi.serverFunctionName(1, 2, 3)\nyourApi.clientFunctionName(1, 2, 3)\n\n-- from anywhere:\n\nyourApi.commonFunctionName(1, 2, 3)\n```\n\nAnd there you have it! You didn't even have to touch RemoteEvents, RemoteFunctions, etc., but server-side functions are only executed on the server, and client-side functions are only executed on clients.\nIt's RbxRPC magic!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficonmaster5326%2Frbxrpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ficonmaster5326%2Frbxrpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficonmaster5326%2Frbxrpc/lists"}