Roblox tutorial · MCP

Roblox Studio + AI: build a game just by describing it

Roblox Studio now ships with a built-in MCP server. AI agents such as Claude Code, Cursor or OpenCode can read your place, write Luau scripts, insert objects, press Play and read errors from Output. You describe the game; BangunWeb supplies the AI tokens, pay once, no subscription.

About 10 minutes Studio steps follow the official Roblox documentation (November 2026). Keys and models tested live against router.bangunweb.com.

The three values you need

Base URL (Anthropic) · Claude Code
https://router.bangunweb.com
Base URL (OpenAI compatible) · Cursor, OpenCode, NPC
https://router.bangunweb.com/v1
API key
bwr_live_YOUR_KEY

Sign in and create an API key to have the blocks below filled in automatically. Until then you will see the example bwr_live_YOUR_KEY.

Get an API key →

Pick your path

There are three ways to use AI for Roblox. Start with the one that fits; all of them use the same token balance.

APath A: connect an AI agent to Roblox Studio (MCP)

MCP is the standard "plug" that lets AI agents use other apps. Roblox Studio provides it out of the box, so there is no plugin or extra download.

  1. Update Roblox Studio

    Open the latest Roblox Studio on Windows or Mac. The built-in MCP server only exists in recent versions. Keep Studio open while the AI works; it can only change the place that is open.

  2. Turn on the MCP server in Studio

    Open the Assistant panel, click the three-dot (...) button, choose Manage MCP Servers and enable "Enable Studio as MCP server". Save your place once by hand (File > Save) so the AI can save it later.

  3. Install an AI agent with your BangunWeb key

    Fastest: the one-line Claude Code installer below. It signs in through your browser, installs Claude Code if needed and writes your BangunWeb key into its settings. Prefer Cursor, OpenCode or Gemini CLI? Follow that tool's guide, then come back to step 4.

    Claude Code · macOS / Linux
    curl -fsSL https://bangunweb.com/install/claude | BANGUNWEB_MODEL=bw-focus sh
    Claude Code · Windows PowerShell
    irm https://bangunweb.com/install/claude.ps1 | iex

    Claude Code · Cursor · Gemini CLI · OpenCode / API

  4. Connect the agent to Studio

    Easiest: in Studio open Assistant > ... > Manage MCP Servers > Quick connect and toggle Claude Code (or Cursor / Gemini CLI). If it is missing, restart Studio, or add it by hand with the command below for your tool and OS.

    Add it by hand (when Quick connect is missing)

    Claude Code · Windows
    claude mcp add --transport stdio Roblox_Studio -- cmd.exe /c "%LOCALAPPDATA%\Roblox\mcp.bat"
    Claude Code · macOS
    claude mcp add --transport stdio Roblox_Studio -- /Applications/RobloxStudio.app/Contents/MacOS/StudioMCP
    Cursor · ~/.cursor/mcp.json (Windows)
    {
      "mcpServers": {
        "Roblox_Studio": {
          "command": "cmd.exe",
          "args": ["/c", "%LOCALAPPDATA%\\Roblox\\mcp.bat"]
        }
      }
    }
    Cursor · ~/.cursor/mcp.json (macOS)
    {
      "mcpServers": {
        "Roblox_Studio": {
          "command": "/Applications/RobloxStudio.app/Contents/MacOS/StudioMCP"
        }
      }
    }
    OpenCode · opencode.json (Windows)
    {
      "$schema": "https://opencode.ai/config.json",
      "mcp": {
        "roblox_studio": {
          "type": "local",
          "command": ["cmd.exe", "/c", "%LOCALAPPDATA%\\Roblox\\mcp.bat"],
          "enabled": true
        }
      }
    }
    OpenCode · opencode.json (macOS)
    {
      "$schema": "https://opencode.ai/config.json",
      "mcp": {
        "roblox_studio": {
          "type": "local",
          "command": ["/Applications/RobloxStudio.app/Contents/MacOS/StudioMCP"],
          "enabled": true
        }
      }
    }
  5. Check the connection

    Open a terminal in an empty folder (for example my-game), run claude and type /mcp. Roblox_Studio must show as connected. In Studio a green indicator shows how many clients are connected.

  6. Send your first prompt

    Start small, for example: "Look at this place first, then create a red spinning part in the middle of Workspace". Once it works, move on to the prompts below. Save often.

With more than one Studio window open, ask the AI to run list_roblox_studios first so it edits the right game. The MCP server only saves (save_place); it never publishes, you still press Publish yourself.

What the AI can do in Studio

Read and edit scripts

script_read, script_search, script_grep, multi_edit: find and change many scripts at once.

Run Luau code

execute_luau in Edit, Client or Server context: create folders, parts and GUIs, set properties.

Test on its own

start_stop_play, get_console_output, screen_capture: press Play, read errors in Output, take a screenshot and fix.

Drive a test character

character_navigation, user_keyboard_input, user_mouse_input: walk, jump and click buttons during a playtest.

Create and find assets

generate_mesh, generate_material, generate_procedural_model, search_asset, insert_asset from the Creator Store.

Explore the place

search_game_tree and inspect_instance: understand Workspace, ServerScriptService, StarterGui and more.

Ready-to-copy prompts

One feature per prompt is cheaper and fails less. When the AI is done, ask it to press Play and read Output.

10-stage obby
Build a 10-stage obby in Workspace that gets harder as it climbs: jumps, disappearing parts, lava (KillPart) and conveyors. Every stage gets a checkpoint (SpawnLocation) and a stage number sign. Then press Play, run the character from the start to stage 2 and fix any errors in Output.
Coins and leaderboard
Add 30 spinning coins along the obby. When touched, a coin disappears for 10 seconds and the player's Coins in leaderstats goes up by 1. Save Coins with DataStoreService (use pcall, save on PlayerRemoving and BindToClose).
Item shop
Create a shop GUI in StarterGui (a Shop button on the left). Three items: Speed Coil 50 coins, Gravity Coil 80 coins, Trail 120 coins. Validate purchases on the server through a RemoteEvent and deduct coins on the server; never trust the client.
Round system
Create a round system: 20-second lobby, teleport players to the arena, 90-second round, survivors get 10 coins, then back to the lobby. Show a countdown at the top of every player's screen.
Enemy NPC
Create a zombie NPC in the arena that chases the nearest player with PathfindingService, deals 10 damage per second on touch, has a 100 HP Humanoid and respawns 5 seconds after dying.
Day and night
Create a 10-minute day-night cycle in Lighting. At night turn on the PointLight in every lamp post (models named Lamp) and turn them off during the day.
Fix errors
Press Play for 20 seconds, read Output, explain every error in plain words, then fix them one by one. Press Play again to confirm Output is clean.
Clean up and secure
Review every script in this place. Look for exploits (RemoteEvents that trust the client, currency changed on the client), duplicate scripts and heavy loops. Write the list of findings first, wait for my approval, then fix.
Main menu
Create a full-screen main menu when a player joins: game title, Play, Shop and Settings (music volume). Clean style with UICorner, UIStroke and smooth TweenService animations. Make sure it fits phone screens.
Explain a game
Explain this place to me as a beginner: which scripts exist, what each does and how they connect. Do not change anything.

BPath B: ask for scripts in a chat, then paste into Studio

Good when you do not have a strong computer yet or want to learn step by step. The AI never touches Studio; you paste the scripts.

  1. Open an AI chat with BangunWeb tokens

    Use the BangunWeb Agent in your dashboard, or any chat app that accepts a custom base URL (for example Chatbox on a phone: Settings > Model Provider > Add > OpenAI API Compatible, API Host https://router.bangunweb.com/v1 and your bwr_live_ key).

    Open BangunWeb Agent

  2. Describe it fully

    Say which script type (Script on the server, LocalScript on the client, or ModuleScript), where it goes (ServerScriptService, StarterPlayerScripts, StarterGui) and what should happen in play. Example: "Write a Script for ServerScriptService: every player who joins gets leaderstats Coins = 0".

    Prompt template for a chat
    You are a Roblox Luau expert. Write complete code for this feature: (describe the feature).
    For every script state: type (Script / LocalScript / ModuleScript), its exact location in Explorer, and the names of objects I need to create.
    Use modern Luau (task.wait, not wait), validate on the server, and add short comments.
  3. Paste it in the right place

    In Studio right-click the target folder in Explorer > Insert Object > Script / LocalScript, clear the default code and paste. The wrong location is the most common reason a script does nothing.

  4. Test and send errors back

    Press Play. If red text shows in Output (View > Output), copy all of it and send it to the AI: "Here is the error, fix it". Repeat until clean.

CPath C: an AI NPC inside your game

A player types to an NPC, a server script calls the BangunWeb API and the AI answer appears in a chat bubble. Each answer spends tokens from your balance, so use a fast model and limit usage per player.

  1. Allow HTTP requests

    In Studio open File > Experience Settings > Security, enable Allow HTTP Requests and Save. The experience must be published to Roblox.

  2. Store the API key as a Secret

    Never put the key inside a script: anyone with a copy of the place could steal it. In the Creator Dashboard open your experience > Secrets > Create Secret, name bangunweb, value your bwr_live_ key, domain router.bangunweb.com. Secrets are not readable in a local Studio playtest: for testing also add it under File > Experience Settings > Security > Local Secrets with the same name.

  3. Create the server script

    In ServerScriptService create a Script named NpcAI and paste the code below. Also create a RemoteEvent named TanyaNPC in ReplicatedStorage and fire it from your button or ProximityPrompt LocalScript.

    ServerScriptService > NpcAI (Script)
    -- AI NPC using the BangunWeb API (OpenAI compatible).
    -- Needs: Allow HTTP Requests = ON, a Secret named "bangunweb", RemoteEvent ReplicatedStorage.TanyaNPC
    local HttpService = game:GetService("HttpService")
    local TextService = game:GetService("TextService")
    local ReplicatedStorage = game:GetService("ReplicatedStorage")
    
    local URL = "https://router.bangunweb.com/v1/chat/completions"
    local MODEL = "bw-swift"
    local SYSTEM = "You are Old Raka, the village guard in this Roblox game. Answer briefly (max 2 sentences), friendly, suitable for all ages. Only talk about this game. Never ask for personal information. If a player seems very sad or wants to hurt themselves, suggest talking to a trusted adult."
    
    local ask = ReplicatedStorage:WaitForChild("TanyaNPC")
    local cooldown = {}
    
    local function askAI(question)
    	local key = HttpService:GetSecret("bangunweb")
    	key = key:AddPrefix("Bearer ")
    	local ok, res = pcall(function()
    		return HttpService:RequestAsync({
    			Url = URL,
    			Method = "POST",
    			Headers = { ["Content-Type"] = "application/json", ["Authorization"] = key },
    			Body = HttpService:JSONEncode({
    				model = MODEL,
    				max_tokens = 200,
    				messages = {
    					{ role = "system", content = SYSTEM },
    					{ role = "user", content = question },
    				},
    			}),
    		})
    	end)
    	if not ok or not res.Success then
    		warn("NPC AI failed:", ok and res.StatusCode or res)
    		return nil
    	end
    	local data = HttpService:JSONDecode(res.Body)
    	return data.choices and data.choices[1] and data.choices[1].message.content
    end
    
    ask.OnServerEvent:Connect(function(player, text)
    	if typeof(text) ~= "string" or #text == 0 or #text > 200 then return end
    	if cooldown[player] and os.clock() - cooldown[player] < 8 then return end
    	cooldown[player] = os.clock()
    
    	local answer = askAI(text) or "Sorry, Old Raka is daydreaming. Try again."
    	local okF, result = pcall(function()
    		return TextService:FilterStringAsync(answer, player.UserId)
    	end)
    	if not okF then return end
    	local safe = result:GetNonChatStringForBroadcastAsync()
    	ask:FireAllClients(player, safe)
    end)
    
    game:GetService("Players").PlayerRemoving:Connect(function(p) cooldown[p] = nil end)
  4. Follow Roblox AI rules

    AI text must be filtered before it is shown (the code uses TextService:FilterStringAsync). Show "This NPC is answered by AI, not a human, and may be wrong" near the NPC, and declare AI use in the Content Ratings Questionnaire. Keep the NPC a side feature (short Q&A). Experiences whose main purpose is open-ended AI chat, or that keep AI memory across sessions, get a Restricted (18+) rating.

  5. Save tokens

    Use a fast model (bw-swift), cap answers (max_tokens 200), rate-limit each player (the code allows 1 question per 8 seconds) and keep only the last few messages of history.

HttpService only works from a server Script, not a LocalScript. Each Roblox server is limited to about 500 external HTTP requests per minute, so the per-player cooldown also keeps a busy server working.

Make your tokens last

One feature per prompt

"Build the whole game" makes the AI read and write a lot. Split it: map, then coins, then shop.

Start fresh often

After a feature is done and the place is saved, type /clear (Claude Code) or open a new chat. Long history is sent with every step.

Match the model to the job

Use bw-focus to build features and bw-swift for light work like colours, text or explanations. Original Claude models cost the most per step.

Go easy on screenshots

screen_capture uses many tokens. Have the AI read Output first and only screenshot when it needs to see a GUI.

Recommended models for coding

Pulled from the live catalog: only models that are currently active. Mode names (bw-...) never change and automatically fail over to a backup model when the main one has trouble.

ModelBest for Estimated cost per stepSuccess, 7 days
Focus (DeepSeek V4 Pro)mode bw-focus Everyday coding agent. The main pick.reads images $0.0028 99.9%
DeepSeek V4 Pro deepseek-v4-pro The model behind Focus, if you want a fixed model.reads images $0.0028 99.9%
Swift (DeepSeek V4.1 Flash)mode bw-swift Light tasks, summaries, titles, the small model.reads images $0.00078 100%
GPT 6 Sol gpt-6-sol Complex logic and code review.reads images $0.0013 100%
Apex (Claude Opus 5.5)mode bw-apex The hardest tasks. Much higher cost per request.reads images $0.080 99.3%
Claude Sonnet 5.5 claude-sonnet-5.5 Claude directly. Use sparingly.reads images $0.052 100%

One step = one typical coding-agent request (about 20 thousand tokens in and 1 thousand out) at the Saver package rate. A coding agent can send dozens of steps for a single task.

Questions and troubleshooting

Can I make a Roblox game with vibe coding only?

Yes, especially obbies, simple tycoons, simulators and minigames. You describe the feature; the AI writes Luau and tests it in Studio. Bigger games still need you to steer, playtest and decide the design.

Can I do this from a phone?

Roblox Studio only runs on Windows and Mac, so Paths A and C need a computer. From a phone you can use Path B to prepare scripts and learn.

Can I use these tokens in the Roblox built-in Assistant?

The built-in Assistant only accepts keys straight from specific providers. The way to use BangunWeb tokens is through an external agent (Claude Code, Cursor, OpenCode, Gemini CLI) connected to Studio over MCP, as in Path A.

Roblox_Studio is missing or failed in /mcp

Make sure Studio is open and "Enable Studio as MCP server" is on. Restart Studio and the agent. Check the command path: Windows %LOCALAPPDATA%\Roblox\mcp.bat, Mac /Applications/RobloxStudio.app/Contents/MacOS/StudioMCP. If you wrote JSON by hand, check commas and brackets.

Claude Code asks me to log in to claude.ai

Your BangunWeb key is not being read. Run the one-line installer again, or follow the Claude Code guide (ANTHROPIC_BASE_URL https://router.bangunweb.com without /v1 and ANTHROPIC_AUTH_TOKEN).

The AI says it saved, but the live game has not changed

save_place only saves the place in Studio; it does not publish. Press File > Publish to Roblox yourself once you have checked the result.

The AI NPC is silent, or I see "HTTP requests are not enabled" / "Can't find secret"

Enable Allow HTTP Requests in File > Experience Settings > Security and make sure a Secret named bangunweb exists (Creator Dashboard > Secrets for live servers, Local Secrets in Experience Settings for Studio tests). Check the "NPC AI failed" warning in Output: 401 = wrong key, 402 = out of tokens.

Is it safe to let the AI edit my game?

It only edits the open place and never publishes. Still keep a copy (File > Save to File As) before big changes and ask the AI to write a plan first.

How much does it cost?

You pay per token, depending on the model. The table below estimates the cost per step. One feature usually takes a dozen to a few dozen steps. New accounts get free trial tokens and token packs never expire.

Related guides

Start building Roblox games with AI

One key for DeepSeek, GPT, Claude and dozens of other models. Pay per token, no subscription. Sign up free, get 2M test tokens.