Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/brockmartin/roblox-game-skill/llms.txt

Use this file to discover all available pages before exploring further.

The Debug Loop is a structured, iterative workflow for diagnosing and resolving Roblox game bugs. Rather than making a single guess, it methodically collects the raw error output, reads the relevant source code, categorizes the root cause, generates a focused fix, and retests — repeating up to five times before escalating to you with a detailed findings report. Use this workflow whenever a script error appears in the Output panel or a playtest produces unexpected behavior. Trigger: You report an error, paste a stack trace, or ask Claude to “fix this bug” / “debug my game” / “something is broken”.
1

Error Gathering

Claude collects the raw error output before attempting any fix.
Calls get_playtest_output to retrieve runtime errors from the most recent playtest session. Falls back to get_console_output if no playtest is active.
Claude records four data points for each error:
  • Exact error string (e.g., ServerScriptService.CombatHandler:42: attempt to index nil with 'Character')
  • Script path and line number
  • Whether the error fires once, intermittently, or in a loop
  • Whether the origin is server-side or client-side
2

Code Discovery

Claude locates and reads the source code surrounding the error.
Uses grep_scripts with keywords extracted from the error (function names, variables, service names) to find all relevant scripts. Reads each with get_script_source.
Claude reads 10–20 lines of surrounding context around the error line and traces the require chain for any modules that feed data into the failing function.
3

Root Cause Analysis

Claude categorizes the error into one of five buckets and selects the appropriate fix pattern.
CategoryCommon SignsFix Pattern
Syntax ErrorMissing end/then/do, mismatched brackets, typo in keywordCorrect the token; Luau’s error message usually points directly at it
Runtime Errorattempt to index nil, type mismatch, missing serviceAdd nil guards, type checks, or WaitForChild with timeout
Logic ErrorNo error thrown but wrong behavior; incorrect calculation or inverted conditionalTrace data flow with print statements to find where actual values diverge from expected
Security IssueClient sending unvalidated data, damage computed client-sideMove authority to server; validate every remote argument
Performance IssueFPS drop, memory climb, runaway Heartbeat loopProfile with MicroProfiler, pool objects, debounce events
Common nil-reference causes in Roblox:
  • Player.Character accessed before the character has loaded
  • FindFirstChild returning nil and the result used without a guard
  • A RemoteEvent payload that the client did not send
  • WaitForChild timing out and returning nil (with timeout argument)
4

Generate Fix

Claude produces corrected Luau code. Every fix includes three parts:
  1. What was wrong — a plain-language explanation of the bug
  2. Why the fix works — the specific change and reasoning
  3. The corrected code — the full function or block, not a one-line diff
Example: nil Character guard before a combat hit
-- BEFORE (buggy): Character may not exist yet
RemoteEvent.OnServerEvent:Connect(function(player, targetId)
    local character = player.Character
    local humanoid  = character.Humanoid  -- errors if Character is nil
    humanoid:TakeDamage(10)
end)

-- AFTER (fixed): guard against nil Character
RemoteEvent.OnServerEvent:Connect(function(player, targetId)
    local character = player.Character
    if not character then return end

    local humanoid = character:FindFirstChildOfClass("Humanoid")
    if not humanoid or humanoid.Health <= 0 then return end

    humanoid:TakeDamage(10)
end)
Fix guidelines Claude follows:
  • Preserve the original code’s style and naming conventions
  • Do not introduce unrelated refactors in the same fix (keep diffs minimal)
  • If the bug appears in multiple scripts, note all locations
5

Apply and Retest

Claude applies the fix and immediately retests.
  1. execute_luau — inject corrected source into the session
  2. start_playtest — launch a new test
  3. get_playtest_output — capture output and check for the original error
6

Verify and Iterate

Claude scans the full output — not just for the original error string — to catch any newly introduced issues.If the error is gone: Proceed to the summary step.If the error persists or a new error appears: Capture the updated diagnostic data and return to Step 1 with a new iteration. Each iteration is appended to a running log:
Iteration 1: Nil reference on Character — added WaitForChild guard — error persists (different line).
Iteration 2: Missing Humanoid check — added FindFirstChildOfClass guard — clean run.
The debug loop caps at 5 iterations. If the bug is not resolved after five passes, Claude stops attempting automatic fixes and presents a findings summary: each iteration’s hypothesis, attempted fix, and result, plus remaining theories and suggested manual investigation steps (MicroProfiler, verbose logging, minimal repro place).
7

Bug Report

Once resolved, Claude documents the outcome using a standard template:
## Bug Report

**Error:** [exact error message]
**Script:** [full script path]
**Line:** [line number]

**Root Cause Category:** [Syntax | Runtime | Logic | Security | Performance]

**Root Cause Description:**
[Plain-language explanation of why the bug occurred.]

**Fix Applied:**
[Description of the change and the corrected code block.]

**Iterations Required:** [1–5]

**Preventive Advice:**
- Always nil-check Player.Character before accessing Humanoid.
- Validate all RemoteEvent arguments on the server before processing.
- Use FindFirstChildOfClass instead of direct property indexing on Characters.
If the root cause reveals a pattern that could affect other scripts, Claude flags all affected locations. If the issue is a common Roblox gotcha not covered in the reference docs, it is flagged for addition.

What to Do After 5 Failed Attempts

If five iterations do not resolve the bug, Claude provides:
  • A numbered log of every hypothesis, fix attempt, and result
  • The current error state and suspected remaining causes
  • Concrete manual investigation steps:
    • Enable MicroProfiler (Ctrl+F6) to identify frame spikes
    • Add print() statements at key data boundaries to trace actual values
    • Isolate the failing logic in a minimal, empty Roblox place to rule out interactions
    • Check the Developer Console (F9) for errors that do not appear in the Studio output panel
For bugs rooted in security patterns (client-trusted logic, unvalidated remotes), see Security Hardening for the full validation and rate-limiting patterns. For performance-related bugs (FPS drops, memory leaks), the Performance Audit workflow covers profiling in more depth.

Build docs developers (and LLMs) love