rbxluau
v2.2.0
Published
All-in-one toolkit to seamlessly execute Roblox Luau
Readme
Roblox Luau Execute
A Node.js project for executing Luau scripts, designed for use with Roblox development workflows. This project provides tools and utilities to run and manage Luau scripts programmatically.
Setup
Local Execution:
Install roblox-luau-execute via npm:
npm install rbxluauEnsure you have Roblox Studio installed and opened at least once on your local machine.
Start using the package in your Node.js projects!
npx rbxluau "print('Hello, Roblox!')"
Cloud Execution (CI/CD Pipelines, etc.):
Create and log into a throwaway Roblox account to use for script execution on an incognito browser window. Ensure this account has no value and is not linked to any personal information.
Disable account session protection. This is necessary for the API to work outside of your local machine.
Obtain the
.ROBLOSECURITYcookie value from your browser. This cookie is required for authentication when making API requests. Do not log out of this account. Instead, just close the incognito window after obtaining the cookie, as logging out will invalidate the cookie.In your project directory, create a
.envfile and add the following line, replacingyour_roblosecurity_cookiewith your actual cookie value:ROBLOSECURITY=your_roblosecurity_cookieAdditionally, you can also specify multiple cookies by separating them with commas, allowing for load balancing across accounts:
ROBLOSECURITY=cookie1,cookie2,cookie3Install roblox-luau-execute via npm:
npm install rbxluauStart using the package in your Node.js projects!
npx rbxluau "print('Hello, Roblox!')"
Alternative: Using Exported Credentials
For CI/CD environments, you can export your credentials on your local machine and use them as an environment variable instead of the ROBLOSECURITY cookie:
After running cloud execution at least once (which creates the
.rbxluaufolder), export your credentials:npx rbxluau export-credentialsCopy the JSON output and set it as the
RBXLUAU_CREDENTIALSenvironment variable:RBXLUAU_CREDENTIALS='...'Now you can run scripts without needing ROBLOSECURITY in your environment:
npx rbxluau "print('Hello, Roblox!')"
This approach is particularly useful for CI/CD pipelines since ROBLOSECURITY cookies are prone to expiration and also pose security risks if mishandled.
Getting Started
Prerequisites
- Node.js (v16 or later recommended)
- Roblox Studio (optional, for local execution)
Installation
- Clone the repository:
git clone https://github.com/your-username/roblox-luau-execute.git cd roblox-luau-execute - Install dependencies:
npm install
Running a Luau Script
You can run a Luau script using the provided demo:
npx rbxluau --script demo/fibonacci.luauCapture CLI output to a file using the --out option:
npx rbxluau --script demo/fibonacci.luau --out logs/fibonacci.logCombine --out with --silent to suppress console logs, and --no-exit when embedding the CLI so it resolves without calling process.exit:
npx rbxluau --script demo/fibonacci.luau --out logs/fibonacci.log --silent --no-exitOr run the demo TypeScript project:
npm run buildYour Luau script can return an exit code by returning a number at the end of the script. For example, returning 1 will set the process exit code to 1.
License
This project is licensed under the MIT License. See the LICENSE file for details.
