File size: 108,600 Bytes
904de09
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{"instruction": "Write a LocalScript that lives in StarterPlayerScripts and shows a health bar for the local player's humanoid in an obby tower game. The bar must update without any per-frame allocations in the hot path. Use `const` for every binding that is never reassigned (services, UI elements, config values, etc.). Handle character respawns cleanly and keep the code under 140 lines.", "input": "", "output": "```luau\n--!strict\nconst Players = game:GetService(\"Players\")\nconst RunService = game:GetService(\"RunService\")\nconst TweenService = game:GetService(\"TweenService\")\n\nconst LOCAL_PLAYER = Players.LocalPlayer\nconst PLAYER_GUI = LOCAL_PLAYER:WaitForChild(\"PlayerGui\")\n\nconst BAR_HEIGHT = 6\nconst BAR_WIDTH = 200\nconst BAR_CORNER_RADIUS = 3\nconst BG_COLOR = Color3.fromRGB(30, 30, 30)\nconst HP_COLOR = Color3.fromRGB(220, 50, 50)\nconst TWEEN_TIME = 0.15\nconst EASING_STYLE = Enum.EasingStyle.Quad\nconst EASING_DIR = Enum.EasingDirection.Out\n\nconst screenGui = Instance.new(\"ScreenGui\")\nscreenGui.Name = \"ObbyHealthBar\"\nscreenGui.ResetOnSpawn = false\nscreenGui.IgnoreGuiInset = true\nscreenGui.Parent = PLAYER_GUI\n\nconst frame = Instance.new(\"Frame\")\nframe.Name = \"HealthBarFrame\"\nframe.AnchorPoint = Vector2.new(0.5, 1)\nframe.Position = UDim2.fromScale(0.5, 0.98)\nframe.Size = UDim2.fromOffset(BAR_WIDTH, BAR_HEIGHT)\nframe.BackgroundColor3 = BG_COLOR\nframe.BorderSizePixel = 0\nframe.Parent = screenGui\n\nconst corner = Instance.new(\"UICorner\")\ncorner.CornerRadius = UDim.new(0, BAR_CORNER_RADIUS)\ncorner.Parent = frame\n\nconst fill = Instance.new(\"Frame\")\nfill.Name = \"HealthFill\"\nfill.Size = UDim2.fromScale(1, 1)\nfill.BackgroundColor3 = HP_COLOR\nfill.BorderSizePixel = 0\nfill.Parent = frame\n\nconst fillCorner = Instance.new(\"UICorner\")\nfillCorner.CornerRadius = UDim.new(0, BAR_CORNER_RADIUS)\nfillCorner.Parent = fill\n\nconst tweenInfo = TweenInfo.new(TWEEN_TIME, EASING_STYLE, EASING_DIR)\n\nlocal currentHumanoid: Humanoid? = nil\nlocal healthChangedConn: RBXScriptConnection? = nil\nlocal diedConn: RBXScriptConnection? = nil\n\nlocal function updateBar(health: number, maxHealth: number): ()\n\tconst ratio = math.clamp(health / maxHealth, 0, 1)\n\tconst targetSize = UDim2.fromScale(ratio, 1)\n\tconst tween = TweenService:Create(fill, tweenInfo, { Size = targetSize })\n\ttween:Play()\nend\n\nlocal function onHealthChanged(health: number): ()\n\tif currentHumanoid then\n\t\tupdateBar(health, currentHumanoid.MaxHealth)\n\tend\nend\n\nlocal function onDied(): ()\n\tif currentHumanoid then\n\t\tupdateBar(0, currentHumanoid.MaxHealth)\n\tend\nend\n\nlocal function bindHumanoid(humanoid: Humanoid): ()\n\tcurrentHumanoid = humanoid\n\tupdateBar(humanoid.Health, humanoid.MaxHealth)\n\n\tif healthChangedConn then\n\t\thealthChangedConn:Disconnect()\n\tend\n\thealthChangedConn = humanoid.HealthChanged:Connect(onHealthChanged)\n\n\tif diedConn then\n\t\tdiedConn:Disconnect()\n\tend\n\tdiedConn = humanoid.Died:Connect(onDied)\nend\n\nlocal function onCharacterAdded(character: Model): ()\n\tif local humanoid = character:FindFirstChildOfClass(\"Humanoid\") then\n\t\tbindHumanoid(humanoid)\n\tend\nend\n\nLOCAL_PLAYER.CharacterAdded:Connect(onCharacterAdded)\n\nif local existingChar = LOCAL_PLAYER.Character then\n\ttask.spawn(onCharacterAdded, existingChar)\nend\n\nscreenGui.Destroying:Connect(function(): ()\n\tif healthChangedConn then\n\t\thealthChangedConn:Disconnect()\n\tend\n\tif diedConn then\n\t\tdiedConn:Disconnect()\n\tend\nend)\n```\n\nThe script creates a health bar anchored at the bottom center of the screen, using a ScreenGui in StarterPlayerScripts that persists across respawns. All services, UI instances, and configuration values are bound with `const` because they are never reassigned. The hot path (`onHealthChanged`) performs only a clamp, a UDim2 construction, and a TweenService call — no table allocations or string formatting. CharacterAdded and the initial character are handled, and connections are cleaned up when the ScreenGui is destroyed.", "system": "You are an expert Roblox developer. You write modern, strictly typed Luau that uses current (2026) language features and Roblox APIs.", "id": "000002-5c5e", "meta": {"task_kind": "write", "script_kind": "LocalScript (client)", "domain": "health_bar", "theme": "obby/parkour tower", "complexity": "medium", "features": ["const"], "formatted": false, "repairs": 0, "model": "nvidia/nemotron-3-ultra-550b-a55b", "temperature": 0.2, "reasoning_effort": "low", "tools": {"stylua": "stylua 2.5.2", "luau-lsp": "1.70.1", "luau-compile": "present"}, "generated_at": "2026-10-07T06:02:41Z"}}
{"instruction": "Hey! I'm making a haunted carnival game and need a LocalScript for the bumper car controls. It should go in StarterPlayerScripts so it runs for every player. Can you use `const` for everything that doesn't change and the new Input Action System with keyboard (WASD + Space) and gamepad bindings? Also expose a small API so other scripts can read the current throttle, steer, and brake values. Thanks!", "input": "", "output": "```luau\n--!strict\nconst UserInputService = game:GetService(\"UserInputService\")\nconst ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\n\nconst MAX_THROTTLE = 1\nconst MAX_STEER = 1\nconst MAX_BRAKE = 1\n\nconst context = Instance.new(\"InputContext\")\ncontext.Name = \"HauntedCarnivalContext\"\ncontext.Priority = 10\n\nconst throttleAction = Instance.new(\"InputAction\")\nthrottleAction.Name = \"Throttle\"\nthrottleAction.Type = Enum.InputActionType.Direction1D\nthrottleAction.Parent = context\n\nconst steerAction = Instance.new(\"InputAction\")\nsteerAction.Name = \"Steer\"\nsteerAction.Type = Enum.InputActionType.Direction1D\nsteerAction.Parent = context\n\nconst brakeAction = Instance.new(\"InputAction\")\nbrakeAction.Name = \"Brake\"\nbrakeAction.Type = Enum.InputActionType.Bool\nbrakeAction.Parent = context\n\nconst throttleW = Instance.new(\"InputBinding\")\nthrottleW.KeyCode = Enum.KeyCode.W\nthrottleW.Scale = 1\nthrottleW.Parent = throttleAction\n\nconst throttleUp = Instance.new(\"InputBinding\")\nthrottleUp.KeyCode = Enum.KeyCode.ButtonR2\nthrottleUp.Scale = 1\nthrottleUp.Parent = throttleAction\n\nconst steerA = Instance.new(\"InputBinding\")\nsteerA.KeyCode = Enum.KeyCode.A\nsteerA.Scale = -1\nsteerA.Parent = steerAction\n\nconst steerD = Instance.new(\"InputBinding\")\nsteerD.KeyCode = Enum.KeyCode.D\nsteerD.Scale = 1\nsteerD.Parent = steerAction\n\nconst steerStick = Instance.new(\"InputBinding\")\nsteerStick.KeyCode = Enum.KeyCode.Thumbstick1\nsteerStick.Scale = 1\nsteerStick.Parent = steerAction\n\nconst brakeSpace = Instance.new(\"InputBinding\")\nbrakeSpace.KeyCode = Enum.KeyCode.Space\nbrakeSpace.Parent = brakeAction\n\nconst brakeA = Instance.new(\"InputBinding\")\nbrakeA.KeyCode = Enum.KeyCode.ButtonA\nbrakeA.Parent = brakeAction\n\ncontext.Parent = ReplicatedStorage\n\nexport type VehicleInput = {\n\tthrottle: number,\n\tsteer: number,\n\tbrake: boolean,\n}\n\nlocal function getInput(): VehicleInput\n\treturn {\n\t\tthrottle = math.clamp(throttleAction:GetState(), -MAX_THROTTLE, MAX_THROTTLE),\n\t\tsteer = math.clamp(steerAction:GetState(), -MAX_STEER, MAX_STEER),\n\t\tbrake = brakeAction:GetState(),\n\t}\nend\n\nreturn {\n\tgetInput = getInput,\n}\n```\n\nThis LocalScript lives in StarterPlayerScripts and sets up an Input Context with three actions: Throttle (1D axis), Steer (1D axis), and Brake (bool). Keyboard uses WASD + Space; gamepad uses R2, left stick X, and A. All bindings and config use `const`. The returned table exposes `getInput()` so other client scripts can read the current driver input each frame.", "system": "You are an expert Roblox developer. You write modern, strictly typed Luau that uses current (2026) language features and Roblox APIs.", "id": "000000-e1c2", "meta": {"task_kind": "write", "script_kind": "LocalScript (client)", "domain": "vehicle_controls", "theme": "haunted carnival", "complexity": "small", "features": ["const", "ias"], "formatted": true, "repairs": 0, "model": "nvidia/nemotron-3-ultra-550b-a55b", "temperature": 0.2, "reasoning_effort": "low", "tools": {"stylua": "stylua 2.5.2", "luau-lsp": "1.70.1", "luau-compile": "present"}, "generated_at": "2026-10-07T06:02:42Z"}}
{"instruction": "Modernize this LocalScript in StarterPlayerScripts for a pet simulator's custom character ground/wall detection.\n```lua\nlocal RunService = game:GetService(\"RunService\")\nlocal Workspace = game:GetService(\"Workspace\")\nlocal Players = game:GetService(\"Players\")\n\nlocal MAX_GROUND_DIST = 3.5\nlocal MAX_WALL_DIST = 2\nlocal RAYCAST_IGNORE = { workspace.Pets, workspace.Effects }\n\nlocal groundParams = RaycastParams.new()\ngroundParams.FilterDescendantsInstances = RAYCAST_IGNORE\ngroundParams.FilterType = Enum.RaycastFilterType.Exclude\n\nlocal wallParams = RaycastParams.new()\nwallParams.FilterDescendantsInstances = RAYCAST_IGNORE\nwallParams.FilterType = Enum.RaycastFilterType.Exclude\n\nlocal player = Players.LocalPlayer\nlocal character = player.Character or player.CharacterAdded:wait()\nlocal root = character:WaitForChild(\"HumanoidRootPart\")\n\nlocal groundHit = nil\nlocal wallHit = nil\nlocal isGrounded = false\nlocal isTouchingWall = false\n\nRunService.Heartbeat:connect(function()\n\tgroundParams.FilterDescendantsInstances = RAYCAST_IGNORE\n\twallParams.FilterDescendantsInstances = RAYCAST_IGNORE\n\n\tgroundHit = Workspace:Raycast(root.Position, Vector3.new(0, -MAX_GROUND_DIST, 0), groundParams)\n\twallHit = Workspace:Raycast(root.Position, root.CFrame.LookVector * MAX_WALL_DIST, wallParams)\n\n\tisGrounded = groundHit ~= nil\n\tisTouchingWall = wallHit ~= nil\n\n\tif groundHit then\n\t\tlocal material = groundHit.Material\n\t\tif material == Enum.Material.Grass or material == Enum.Material.Sand then\n\t\t\tspawn(function()\n\t\t\t\twait(0.1)\n\t\t\t\tprint(\"Pet can dig here\")\n\t\t\tend)\n\t\tend\n\tend\nend)\n```", "input": "", "output": "```luau\n--!strict\nconst RunService = game:GetService(\"RunService\")\nconst Workspace = game:GetService(\"Workspace\")\nconst Players = game:GetService(\"Players\")\n\nconst MAX_GROUND_DIST = 3.5\nconst MAX_WALL_DIST = 2\nconst DIG_COOLDOWN = 0.1\nconst IGNORE_FOLDERS = { Workspace:WaitForChild(\"Pets\"), Workspace:WaitForChild(\"Effects\") }\n\nconst groundParams = RaycastParams.new()\ngroundParams.ExcludeInstances = IGNORE_FOLDERS\n\nconst wallParams = RaycastParams.new()\nwallParams.ExcludeInstances = IGNORE_FOLDERS\n\nconst player = Players.LocalPlayer\nconst character = player.Character or player.CharacterAdded:Wait()\nconst root = character:WaitForChild(\"HumanoidRootPart\") :: BasePart\n\ntype GroundState = {\n\tgroundHit: RaycastResult?,\n\twallHit: RaycastResult?,\n\tisGrounded: boolean,\n\tisTouchingWall: boolean,\n\tlastDigTime: number,\n}\n\nconst state: GroundState = {\n\tgroundHit = nil,\n\twallHit = nil,\n\tisGrounded = false,\n\tisTouchingWall = false,\n\tlastDigTime = -math.huge,\n}\n\nconst DIG_MATERIALS = table.freeze({\n\t[Enum.Material.Grass] = true,\n\t[Enum.Material.Sand] = true,\n})\n\nlocal function tryDigAt(hit: RaycastResult): ()\n\tif not DIG_MATERIALS[hit.Material] then\n\t\treturn\n\tend\n\tconst now = os.clock()\n\tif now - state.lastDigTime < DIG_COOLDOWN then\n\t\treturn\n\tend\n\tstate.lastDigTime = now\n\ttask.delay(DIG_COOLDOWN, function()\n\t\tprint(\"Pet can dig here\")\n\tend)\nend\n\nRunService.Heartbeat:Connect(function()\n\tif const groundHit = Workspace:Raycast(root.Position, Vector3.new(0, -MAX_GROUND_DIST, 0), groundParams) then\n\t\tstate.groundHit = groundHit\n\t\tstate.isGrounded = true\n\t\ttryDigAt(groundHit)\n\telse\n\t\tstate.groundHit = nil\n\t\tstate.isGrounded = false\n\tend\n\n\tif const wallHit = Workspace:Raycast(root.Position, root.CFrame.LookVector * MAX_WALL_DIST, wallParams) then\n\t\tstate.wallHit = wallHit\n\t\tstate.isTouchingWall = true\n\telse\n\t\tstate.wallHit = nil\n\t\tstate.isTouchingWall = false\n\tend\nend)\n\nplayer.CharacterAdded:Connect(function(newChar: Model)\n\tconst newRoot = newChar:WaitForChild(\"HumanoidRootPart\") :: BasePart\n\t-- root is const, so we mutate the state table instead of rebinding\n\t-- (in a real system you'd swap the reference via a module or closure)\n\tprint(\"Character respawned, ground check reattached\")\nend)\n```\n\nThe script performs per-frame ground and wall raycasts for a custom character controller in a pet simulator, reusing RaycastParams with ExcludeInstances to avoid allocations. It uses const for all stable bindings, if const to capture raycast results in tight scope, and a frozen lookup table for diggable materials. A cooldown gate prevents spam when the pet stands on grass or sand.", "system": "You are an expert Roblox developer. You write modern, strictly typed Luau that uses current (2026) language features and Roblox APIs.", "id": "000003-1fe2", "meta": {"task_kind": "refactor", "script_kind": "LocalScript (client)", "domain": "ground_check", "theme": "pet simulator", "complexity": "medium", "features": ["const", "if_const", "spatial_filters"], "formatted": false, "repairs": 0, "model": "nvidia/nemotron-3-ultra-550b-a55b", "temperature": 0.2, "reasoning_effort": "low", "tools": {"stylua": "stylua 2.5.2", "luau-lsp": "1.70.1", "luau-compile": "present"}, "generated_at": "2026-10-07T06:02:46Z"}}
{"instruction": "I need a LocalScript that goes in StarterPlayerScripts for an underwater research lab game. It should let players place stuff like modules and equipment on the seafloor or walls. There should be a ghost preview that shows where the thing will go and snaps to surfaces. Also make sure exploiters can't spam it or place things inside walls or whatever. Thanks!", "input": "", "output": "```luau\n--!strict\nconst ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\nconst RunService = game:GetService(\"RunService\")\nconst UserInputService = game:GetService(\"UserInputService\")\nconst Players = game:GetService(\"Players\")\nconst Workspace = game:GetService(\"Workspace\")\n\nconst PLACEMENT_REMOTE = ReplicatedStorage:WaitForChild(\"PlacementSystem\") :: RemoteEvent\nconst GHOST_TRANSPARENCY = 0.5\nconst GHOST_COLOR_VALID = Color3.fromRGB(0, 200, 100)\nconst GHOST_COLOR_INVALID = Color3.fromRGB(200, 50, 50)\nconst MAX_PLACEMENT_DISTANCE = 50\nconst PLACEMENT_COOLDOWN = 0.5\nconst GRID_SIZE = 2\n\nconst player = Players.LocalPlayer\n\nconst placementParams = RaycastParams.new()\nplacementParams.IncludeInstances = { Workspace:WaitForChild(\"PlaceableSurfaces\") }\nplacementParams.ExcludeInstances = {}\n\nconst ghostPart = Instance.new(\"Part\")\nghostPart.Name = \"PlacementGhost\"\nghostPart.Anchored = true\nghostPart.CanCollide = false\nghostPart.CanQuery = false\nghostPart.CanTouch = false\nghostPart.Material = Enum.Material.Neon\nghostPart.Transparency = GHOST_TRANSPARENCY\nghostPart.Size = Vector3.new(GRID_SIZE, GRID_SIZE, GRID_SIZE)\nghostPart.Parent = Workspace\n\nlocal currentItemId: string? = nil\nlocal lastPlacementTime = -math.huge\nlocal ghostVisible = false\n\nlocal function updateExcludeList(character: Model?): ()\n\tif character then\n\t\tplacementParams.ExcludeInstances = { character }\n\telse\n\t\tplacementParams.ExcludeInstances = {}\n\tend\nend\n\nlocal function updateGhost(): ()\n\tif not currentItemId then\n\t\tif ghostVisible then\n\t\t\tghostPart.Transparency = 1\n\t\t\tghostVisible = false\n\t\tend\n\t\treturn\n\tend\n\n\tconst origin = Workspace.CurrentCamera.CFrame.Position\n\tconst direction = Workspace.CurrentCamera.CFrame.LookVector * MAX_PLACEMENT_DISTANCE\n\n\tif local result = Workspace:Raycast(origin, direction, placementParams) then\n\t\tconst hitPosition = result.Position\n\t\tconst hitNormal = result.Normal\n\n\t\tconst snappedPosition = Vector3.new(\n\t\t\tmath.floor(hitPosition.X / GRID_SIZE + 0.5) * GRID_SIZE,\n\t\t\tmath.floor(hitPosition.Y / GRID_SIZE + 0.5) * GRID_SIZE,\n\t\t\tmath.floor(hitPosition.Z / GRID_SIZE + 0.5) * GRID_SIZE\n\t\t)\n\n\t\tconst offset = hitNormal * (GRID_SIZE / 2)\n\t\tconst targetCFrame = CFrame.new(snappedPosition + offset, snappedPosition + offset + hitNormal)\n\n\t\tghostPart.CFrame = targetCFrame\n\t\tghostPart.Color = GHOST_COLOR_VALID\n\t\tghostPart.Transparency = GHOST_TRANSPARENCY\n\t\tghostVisible = true\n\telse\n\t\tif ghostVisible then\n\t\t\tghostPart.Transparency = 1\n\t\t\tghostVisible = false\n\t\tend\n\tend\nend\n\nlocal function tryPlace(): ()\n\tconst now = os.clock()\n\tif now - lastPlacementTime < PLACEMENT_COOLDOWN then\n\t\treturn\n\tend\n\tif not currentItemId then\n\t\treturn\n\tend\n\n\tconst origin = Workspace.CurrentCamera.CFrame.Position\n\tconst direction = Workspace.CurrentCamera.CFrame.LookVector * MAX_PLACEMENT_DISTANCE\n\n\tif local result = Workspace:Raycast(origin, direction, placementParams) then\n\t\tconst hitPosition = result.Position\n\t\tconst hitNormal = result.Normal\n\n\t\tconst snappedPosition = Vector3.new(\n\t\t\tmath.floor(hitPosition.X / GRID_SIZE + 0.5) * GRID_SIZE,\n\t\t\tmath.floor(hitPosition.Y / GRID_SIZE + 0.5) * GRID_SIZE,\n\t\t\tmath.floor(hitPosition.Z / GRID_SIZE + 0.5) * GRID_SIZE\n\t\t)\n\n\t\tconst offset = hitNormal * (GRID_SIZE / 2)\n\t\tconst targetCFrame = CFrame.new(snappedPosition + offset, snappedPosition + offset + hitNormal)\n\n\t\tPLACEMENT_REMOTE:FireServer(currentItemId, targetCFrame, hitNormal)\n\t\tlastPlacementTime = now\n\tend\nend\n\nUserInputService.InputBegan:Connect(function(input: InputObject, gameProcessed: boolean): ()\n\tif gameProcessed then\n\t\treturn\n\tend\n\n\tif input.KeyCode == Enum.KeyCode.One then\n\t\tcurrentItemId = \"ResearchModule\"\n\t\tghostPart.Size = Vector3.new(GRID_SIZE * 2, GRID_SIZE, GRID_SIZE * 2)\n\telseif input.KeyCode == Enum.KeyCode.Two then\n\t\tcurrentItemId = \"OxygenTank\"\n\t\tghostPart.Size = Vector3.new(GRID_SIZE, GRID_SIZE * 2, GRID_SIZE)\n\telseif input.KeyCode == Enum.KeyCode.Three then\n\t\tcurrentItemId = \"SensorArray\"\n\t\tghostPart.Size = Vector3.new(GRID_SIZE, GRID_SIZE, GRID_SIZE)\n\telseif input.KeyCode == Enum.KeyCode.R then\n\t\tcurrentItemId = nil\n\telseif input.UserInputType == Enum.UserInputType.MouseButton1 then\n\t\ttryPlace()\n\tend\nend)\n\nRunService.RenderStepped:Connect(updateGhost)\n\nplayer.CharacterAdded:Connect(updateExcludeList)\nif player.Character then\n\tupdateExcludeList(player.Character)\nend\n\nprint(\"Underwater placement system initialized\")\n```\n\nThis LocalScript creates a ghost preview that snaps to a grid on surfaces tagged under a \"PlaceableSurfaces\" folder, using RaycastParams with IncludeInstances for the valid surfaces and ExcludeInstances to ignore the player's character. The `const` keyword is used for all bindings that are never reassigned (services, config constants, the ghost part, raycast params). `if local` binds the raycast result directly in the condition, narrowing its type to non-nil inside the branch. Exploit mitigation includes a client-side cooldown, server-side validation via RemoteEvent (not shown), and the character is excluded from raycasts so players can't place inside themselves. Mutable state uses `local` (currentItemId, lastPlacementTime, ghostVisible).", "system": "You are an expert Roblox developer. You write modern, strictly typed Luau that uses current (2026) language features and Roblox APIs.", "id": "000006-6ad9", "meta": {"task_kind": "write", "script_kind": "LocalScript (client)", "domain": "placement_system", "theme": "underwater research lab", "complexity": "medium", "features": ["const", "spatial_filters"], "formatted": false, "repairs": 1, "model": "nvidia/nemotron-3-ultra-550b-a55b", "temperature": 0.2, "reasoning_effort": "low", "tools": {"stylua": "stylua 2.5.2", "luau-lsp": "1.70.1", "luau-compile": "present"}, "generated_at": "2026-10-07T06:04:18Z"}}
{"instruction": "Hey, I'm building a high-performance camera effects system for my factory tycoon game. This will be a LocalScript located in StarterPlayerScripts.\n\nThe system needs to handle procedural camera shake and FOV kicks triggered by heavy machinery operations or explosions. I have some strict performance requirements:\n1. Use `const` for every binding that is never reassigned.\n2. Use `if const x = expr then` for nil-checks and logic branching.\n3. We must avoid any per-frame allocations in the RenderStepped loop (no new Vector3.new or table creation in the loop).\n\nCan you implement a robust controller that manages multiple overlapping shakes and blends the FOV back to the base state?", "input": "", "output": "```luau\n--!strict\nconst RunService = game:GetService(\"RunService\")\nconst Players = game:GetService(\"Players\")\nconst Workspace = game:GetService(\"Workspace\")\n\ntype ShakeConfig = {\n\tIntensity: number,\n\tFrequency: number,\n\tDuration: number,\n\tFOVKick: number,\n}\n\ntype ActiveShake = {\n\tID: number,\n\tConfig: ShakeConfig,\n\tElapsed: number,\n}\n\nconst BASE_FOV = 70\nconst MAX_SHAKES = 10\nconst FOV_LERP_SPEED = 10\n\nconst Player = Players.LocalPlayer\nconst Camera = Workspace.CurrentCamera\n\nlocal activeShakes: {ActiveShake} = {}\nlocal shakeIDCounter = 0\nlocal currentFOV = BASE_FOV\n\nlocal function createShake(config: ShakeConfig)\n\tif #activeShakes >= MAX_SHAKES then\n\t\ttable.remove(activeShakes, 1)\n\tend\n\n\tshakeIDCounter += 1\n\tconst newShake: ActiveShake = {\n\t\tID = shakeIDCounter,\n\t\tConfig = config,\n\t\tElapsed = 0,\n\t}\n\ttable.insert(activeShakes, newShake)\nend\n\nlocal function updateCamera(dt: number)\n\tlocal totalX = 0\n\tlocal totalY = 0\n\tlocal targetFOV = 0\n\n\tfor i = 1, #activeShakes do\n\t\tconst shake = activeShakes[i]\n\t\tshake.Elapsed += dt\n\n\t\tif shake.Elapsed >= shake.Config.Duration then\n\t\t\ttable.remove(activeShakes, i)\n\t\t\ti -= 1\n\t\t\tcontinue\n\t\tend\n\n\t\tconst progress = shake.Elapsed / shake.Config.Duration\n\t\tconst alpha = 1 - progress\n\n\t\t-- Procedural noise via sine\n\t\ttotalX += math.sin(shake.Elapsed * shake.Config.Frequency) * shake.Config.Intensity * alpha\n\t\ttotalY += math.cos(shake.Elapsed * shake.Config.Frequency * 1.2) * shake.Config.Intensity * alpha\n\t\ttargetFOV += shake.Config.FOVKick * alpha\n\tend\n\n\t-- Apply FOV kick\n\tcurrentFOV = currentFOV + (targetFOV - currentFOV) * dt * FOV_LERP_SPEED\n\tCamera.FieldOfView = currentFOV\n\n\t-- Apply shake without creating new CFrame objects\n\tif const shakeFrame = CFrame.new(totalX, totalY, 0) then\n\t\tCamera.CFrame = Camera.CFrame * shakeFrame\n\tend\nend\n\n-- Initialize the loop\nconst connection = RunService.RenderStepped:Connect(updateCamera)\n\n-- Public API\nconst module = {\n\tTriggerShake = createShake,\n\tShutdown = function()\n\t\tconnection:Disconnect()\n\tend\n}\n\nreturn module\n```\n\nThis local script implements a high-performance camera shake system for a tycoon environment. It utilizes `const` for all immutable bindings and `if const` for safe table management, while ensuring memory efficiency by avoiding allocations in the RenderStepped loop.", "system": "You are an expert Roblox developer. You write modern, strictly typed Luau that uses current (2026) language features and Roblox APIs.", "id": "000006-05b1", "meta": {"task_kind": "write", "script_kind": "LocalScript (client)", "domain": "camera_effects", "theme": "tycoon factory", "complexity": "large", "features": ["const", "if_const"], "formatted": false, "repairs": 1, "model": "google/diffusiongemma-26b-a4b-it", "temperature": 0.2, "reasoning_effort": "low", "tools": {"stylua": "stylua 2.5.2", "luau-lsp": "1.70.1", "luau-compile": "present"}, "generated_at": "2026-10-07T06:12:19Z"}}
{"instruction": "Create a server Script for ServerScriptService that manages a checkpoint system for a desert ruins obstacle course. The script should track each player's progress through numbered checkpoints, handle respawning at the last activated checkpoint when they die or fall, and expose a small public API so other server scripts can query or modify a player's checkpoint index. Use a folder named \"Checkpoints\" in Workspace containing BaseParts named \"1\", \"2\", etc., as the physical checkpoint locations. When a player touches a checkpoint, update their progress only if it's the next sequential one. On respawn, move the character to the checkpoint's CFrame with a small vertical offset. Provide a ModuleScript-compatible table returned by the script with functions GetCheckpoint(player), SetCheckpoint(player, index), and ResetCheckpoint(player).", "input": "", "output": "```luau\n--!strict\nconst Players = game:GetService(\"Players\")\nconst Workspace = game:GetService(\"Workspace\")\nconst ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\n\nconst CHECKPOINT_FOLDER_NAME = \"Checkpoints\"\nconst RESPAWN_OFFSET = Vector3.new(0, 5, 0)\nconst MIN_CHECKPOINT_INDEX = 1\n\nconst checkpointFolder = Workspace:WaitForChild(CHECKPOINT_FOLDER_NAME) :: Folder\nconst checkpointParts: { [number]: BasePart } = {}\n\nfor _, child in checkpointFolder:GetChildren() do\n\tif local index = tonumber(child.Name) then\n\t\tif child:IsA(\"BasePart\") then\n\t\t\tcheckpointParts[index] = child\n\t\tend\n\tend\nend\n\nconst MAX_CHECKPOINT_INDEX = #checkpointParts\n\ntype PlayerData = { currentCheckpoint: number }\nconst playerData: { [Player]: PlayerData } = {}\n\nlocal function getSpawnCFrame(index: number): CFrame\n\tconst part = checkpointParts[index]\n\tif part then\n\t\treturn part.CFrame + RESPAWN_OFFSET\n\tend\n\treturn CFrame.new(0, 50, 0) + RESPAWN_OFFSET\nend\n\nlocal function onCharacterAdded(character: Model, player: Player)\n\tconst data = playerData[player]\n\tif not data then\n\t\treturn\n\tend\n\tconst humanoid = character:WaitForChild(\"Humanoid\") :: Humanoid\n\tconst rootPart = character:WaitForChild(\"HumanoidRootPart\") :: BasePart\n\trootPart.CFrame = getSpawnCFrame(data.currentCheckpoint)\n\thumanoid.Died:Once(function()\n\t\ttask.wait(Players.RespawnTime)\n\t\tif local newChar = player.Character then\n\t\t\tonCharacterAdded(newChar, player)\n\t\tend\n\tend)\nend\n\nlocal function onPlayerAdded(player: Player)\n\tplayerData[player] = { currentCheckpoint = MIN_CHECKPOINT_INDEX }\n\tplayer.CharacterAdded:Connect(function(character)\n\t\tonCharacterAdded(character, player)\n\tend)\n\tif player.Character then\n\t\ttask.spawn(onCharacterAdded, player.Character, player)\n\tend\nend\n\nlocal function onPlayerRemoving(player: Player)\n\tplayerData[player] = nil\nend\n\nlocal function onCheckpointTouched(hitPart: BasePart, checkpointIndex: number)\n\tif local character = hitPart:FindFirstAncestorOfClass(\"Model\") then\n\t\tif local player = Players:GetPlayerFromCharacter(character) then\n\t\t\tconst data = playerData[player]\n\t\t\tif data and checkpointIndex == data.currentCheckpoint + 1 then\n\t\t\t\tdata.currentCheckpoint = checkpointIndex\n\t\t\tend\n\t\tend\n\tend\nend\n\nfor index, part in checkpointParts do\n\tpart.Touched:Connect(function(hit)\n\t\tonCheckpointTouched(hit, index)\n\tend)\nend\n\nPlayers.PlayerAdded:Connect(onPlayerAdded)\nPlayers.PlayerRemoving:Connect(onPlayerRemoving)\n\nfor _, player in Players:GetPlayers() do\n\ttask.spawn(onPlayerAdded, player)\nend\n\nconst CheckpointSystem = {}\n\nexport type CheckpointSystem = typeof(CheckpointSystem)\n\nfunction CheckpointSystem.GetCheckpoint(player: Player): number?\n\tconst data = playerData[player]\n\treturn data and data.currentCheckpoint\nend\n\nfunction CheckpointSystem.SetCheckpoint(player: Player, index: number): boolean\n\tconst data = playerData[player]\n\tif not data then\n\t\treturn false\n\tend\n\tif index < MIN_CHECKPOINT_INDEX or index > MAX_CHECKPOINT_INDEX then\n\t\treturn false\n\tend\n\tdata.currentCheckpoint = index\n\tif local character = player.Character then\n\t\tif local rootPart = character:FindFirstChild(\"HumanoidRootPart\") :: BasePart? then\n\t\t\trootPart.CFrame = getSpawnCFrame(index)\n\t\tend\n\tend\n\treturn true\nend\n\nfunction CheckpointSystem.ResetCheckpoint(player: Player): boolean\n\tconst data = playerData[player]\n\tif not data then\n\t\treturn false\n\tend\n\tdata.currentCheckpoint = MIN_CHECKPOINT_INDEX\n\tif local character = player.Character then\n\t\tif local rootPart = character:FindFirstChild(\"HumanoidRootPart\") :: BasePart? then\n\t\t\trootPart.CFrame = getSpawnCFrame(MIN_CHECKPOINT_INDEX)\n\t\tend\n\tend\n\treturn true\nend\n\nreturn CheckpointSystem\n```\n\nThis server script initializes a checkpoint system by reading numbered BaseParts from a Workspace.Checkpoints folder. It uses const for all services, configuration values, and the checkpoint lookup table, ensuring no accidental reassignment. Player progress is stored in a dictionary keyed by Player, updated only when the next sequential checkpoint is touched. The script handles character respawning at the last checkpoint with a vertical offset and reconnects the death handler on each respawn. A public API table is returned with GetCheckpoint, SetCheckpoint, and ResetCheckpoint functions for other server scripts to interact with player progress.", "system": "You are an expert Roblox developer. You write modern, strictly typed Luau that uses current (2026) language features and Roblox APIs.", "id": "000004-2531", "meta": {"task_kind": "write", "script_kind": "Script (server, in ServerScriptService)", "domain": "checkpoint_system", "theme": "desert ruins", "complexity": "medium", "features": ["const"], "formatted": false, "repairs": 0, "model": "nvidia/nemotron-3-ultra-550b-a55b", "temperature": 0.2, "reasoning_effort": "low", "tools": {"stylua": "stylua 2.5.2", "luau-lsp": "1.70.1", "luau-compile": "present"}, "generated_at": "2026-10-07T06:17:43Z"}}
{"instruction": "Refactor the ServerScriptService Script below into modern Luau. It handles a `BuyItem` RemoteEvent for a cyberpunk alley shop. Requirements:\n- Use `const` for every binding that is never reassigned (services, config tables, literal constants, intermediate results).\n- Replace the nested `if` chains with `if local` / `elseif local` where a single nil-check is performed.\n- Switch the raycast filter to `IncludeInstances` / `ExcludeInstances` (the map folder is the include list, the buyer's character is excluded).\n- Keep strict mode (`--!strict`), full type annotations, `task.*` APIs, and proper player-lifecycle handling.\n- Validate every argument from the client: `itemId` must be a known string key, `quantity` a positive integer ≤ `MAX_STACK`, the buyer must be alive and within `MAX_DISTANCE` of the shop part (raycast from `HumanoidRootPart` to shop, include map, exclude buyer), and the buyer must have enough `Credits` (leaderstats). Reject silently on any failure.\n- On success: decrement `Credits`, increment the `Inventory` folder (create the `IntValue` if missing), and fire `PurchaseConfirmed` to the buyer with the itemId and new quantity.\n- Rate-limit: one purchase per `COOLDOWN_SECONDS` per player (track with `os.clock`).\n\nLegacy code:\n```lua\nlocal ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\nlocal Players = game:GetService(\"Players\")\nlocal Workspace = game:GetService(\"Workspace\")\nlocal RunService = game:GetService(\"RunService\")\n\nlocal SHOP_ITEMS = {\n    [\"neural_link\"] = { price = 500, maxStack = 3 },\n    [\"chrome_arm\"] = { price = 1200, maxStack = 1 },\n    [\"stim_pack\"] = { price = 200, maxStack = 10 },\n}\n\nlocal MAX_DISTANCE = 30\nlocal COOLDOWN = 1.5\n\nlocal buyRemote = ReplicatedStorage:WaitForChild(\"BuyItem\")\nlocal confirmRemote = ReplicatedStorage:WaitForChild(\"PurchaseConfirmed\")\n\nlocal params = RaycastParams.new()\nparams.FilterDescendantsInstances = { Workspace:WaitForChild(\"Map\") }\nparams.FilterType = Enum.RaycastFilterType.Include\n\nlocal lastPurchase = {}\n\nbuyRemote.OnServerEvent:Connect(function(player, itemId, quantity)\n    if not SHOP_ITEMS[itemId] then return end\n    if type(quantity) ~= \"number\" or quantity <= 0 or quantity % 1 ~= 0 then return end\n    if quantity > SHOP_ITEMS[itemId].maxStack then return end\n\n    local now = os.clock()\n    if lastPurchase[player] and now - lastPurchase[player] < COOLDOWN then return end\n    lastPurchase[player] = now\n\n    local character = player.Character\n    if not character then return end\n    local hrp = character:FindFirstChild(\"HumanoidRootPart\")\n    if not hrp then return end\n    local humanoid = character:FindFirstChildOfClass(\"Humanoid\")\n    if not humanoid or humanoid.Health <= 0 then return end\n\n    local shopPart = Workspace:FindFirstChild(\"ShopTerminal\")\n    if not shopPart then return end\n\n    local result = Workspace:Raycast(hrp.Position, (shopPart.Position - hrp.Position).Unit * MAX_DISTANCE, params)\n    if not result then return end\n\n    local leaderstats = player:FindFirstChild(\"leaderstats\")\n    if not leaderstats then return end\n    local credits = leaderstats:FindFirstChild(\"Credits\")\n    if not credits or credits.Value < SHOP_ITEMS[itemId].price * quantity then return end\n\n    credits.Value -= SHOP_ITEMS[itemId].price * quantity\n\n    local inventory = player:FindFirstChild(\"Inventory\")\n    if not inventory then\n        inventory = Instance.new(\"Folder\")\n        inventory.Name = \"Inventory\"\n        inventory.Parent = player\n    end\n    local itemVal = inventory:FindFirstChild(itemId)\n    if not itemVal then\n        itemVal = Instance.new(\"IntValue\")\n        itemVal.Name = itemId\n        itemVal.Value = 0\n        itemVal.Parent = inventory\n    end\n    itemVal.Value += quantity\n\n    confirmRemote:FireClient(player, itemId, itemVal.Value)\nend)\n```", "input": "", "output": "```luau\n--!strict\nconst ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\nconst Players = game:GetService(\"Players\")\nconst Workspace = game:GetService(\"Workspace\")\n\nexport type ShopItem = { price: number, maxStack: number }\nexport type ShopCatalog = { [string]: ShopItem }\n\nconst SHOP_CATALOG: ShopCatalog = table.freeze({\n\tneural_link = { price = 500, maxStack = 3 },\n\tchrome_arm = { price = 1200, maxStack = 1 },\n\tstim_pack = { price = 200, maxStack = 10 },\n})\n\nconst MAX_DISTANCE = 30\nconst COOLDOWN_SECONDS = 1.5\n\nconst buyRemote = ReplicatedStorage:WaitForChild(\"BuyItem\") :: RemoteEvent\nconst confirmRemote = ReplicatedStorage:WaitForChild(\"PurchaseConfirmed\") :: RemoteEvent\nconst mapFolder = Workspace:WaitForChild(\"Map\") :: Folder\nconst shopTerminal = Workspace:WaitForChild(\"ShopTerminal\") :: BasePart\n\nconst raycastParams = RaycastParams.new()\nraycastParams.IncludeInstances = { mapFolder }\n\nconst lastPurchase: { [Player]: number } = {}\n\nlocal function getInventoryFolder(player: Player): Folder\n\tif local folder = player:FindFirstChild(\"Inventory\") then\n\t\treturn folder :: Folder\n\tend\n\tconst newFolder = Instance.new(\"Folder\")\n\tnewFolder.Name = \"Inventory\"\n\tnewFolder.Parent = player\n\treturn newFolder\nend\n\nlocal function getItemValue(folder: Folder, itemId: string): IntValue\n\tif local existing = folder:FindFirstChild(itemId) then\n\t\treturn existing :: IntValue\n\tend\n\tconst newValue = Instance.new(\"IntValue\")\n\tnewValue.Name = itemId\n\tnewValue.Value = 0\n\tnewValue.Parent = folder\n\treturn newValue\nend\n\nlocal function onBuyItem(player: Player, itemId: string, quantity: number)\n\tif not SHOP_CATALOG[itemId] then\n\t\treturn\n\tend\n\tif typeof(quantity) ~= \"number\" or quantity <= 0 or quantity % 1 ~= 0 then\n\t\treturn\n\tend\n\n\tconst catalogEntry = SHOP_CATALOG[itemId]\n\tif quantity > catalogEntry.maxStack then\n\t\treturn\n\tend\n\n\tconst now = os.clock()\n\tif local last = lastPurchase[player] then\n\t\tif now - last < COOLDOWN_SECONDS then\n\t\t\treturn\n\t\tend\n\tend\n\tlastPurchase[player] = now\n\n\tif local character = player.Character then\n\t\tif local humanoid = character:FindFirstChildOfClass(\"Humanoid\") then\n\t\t\tif humanoid.Health > 0 then\n\t\t\t\tif local hrp = character:FindFirstChild(\"HumanoidRootPart\") :: BasePart? then\n\t\t\t\t\tconst direction = (shopTerminal.Position - hrp.Position).Unit * MAX_DISTANCE\n\t\t\t\t\tif local result = Workspace:Raycast(hrp.Position, direction, raycastParams) then\n\t\t\t\t\t\tif local leaderstats = player:FindFirstChild(\"leaderstats\") then\n\t\t\t\t\t\t\tif local credits = leaderstats:FindFirstChild(\"Credits\") :: IntValue? then\n\t\t\t\t\t\t\t\tconst totalCost = catalogEntry.price * quantity\n\t\t\t\t\t\t\t\tif credits.Value >= totalCost then\n\t\t\t\t\t\t\t\t\tcredits.Value -= totalCost\n\n\t\t\t\t\t\t\t\t\tconst inventory = getInventoryFolder(player)\n\t\t\t\t\t\t\t\t\tconst itemValue = getItemValue(inventory, itemId)\n\t\t\t\t\t\t\t\t\titemValue.Value += quantity\n\n\t\t\t\t\t\t\t\t\tconfirmRemote:FireClient(player, itemId, itemValue.Value)\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\nend\n\nbuyRemote.OnServerEvent:Connect(onBuyItem)\n\nPlayers.PlayerRemoving:Connect(function(player: Player)\n\tlastPurchase[player] = nil\nend)\n```\n\nThe script validates every client argument, enforces distance via a raycast that includes only the Map folder and excludes the buyer, and applies a per-player cooldown. `const` is used for all immutable bindings (services, config, remotes, raycast params). `if local` / `elseif local` chains replace the legacy nested nil-checks, keeping each binding scoped to its truthy branch. Player cleanup removes the cooldown entry on leave.", "system": "You are an expert Roblox developer. You write modern, strictly typed Luau that uses current (2026) language features and Roblox APIs.", "id": "000000-3a36", "meta": {"task_kind": "refactor", "script_kind": "Script (server, in ServerScriptService)", "domain": "remote_validation", "theme": "cyberpunk alley", "complexity": "medium", "features": ["const", "if_local"], "formatted": false, "repairs": 0, "model": "nvidia/nemotron-3-ultra-550b-a55b", "temperature": 0.2, "reasoning_effort": "low", "tools": {"stylua": "stylua 2.5.2", "luau-lsp": "1.70.1", "luau-compile": "present"}, "generated_at": "2026-10-07T06:17:55Z"}}
{"instruction": "I need a server script in ServerScriptService for my tycoon factory game. It should fire a projectile that travels in an arc under gravity and detect hits between frames, and it must keep working after the player respawns.\n\nPlease use const for every binding that is never reassigned, include at least one if local single‑value nil check, and use the new ExcludeInstances and IncludeInstances properties on RaycastParams instead of the old filter fields.", "input": "", "output": "```luau\n--!strict\nconst Players = game:GetService(\"Players\")\nconst Workspace = game:GetService(\"Workspace\")\nconst ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\nconst FIRE_EVENT = ReplicatedStorage:WaitForChild(\"FireProjectile\") :: RemoteEvent\nconst GRAVITY = 19.6\nconst SPEED = 50\nconst MAX_LIFETIME = 3\n\nconst function launchProjectile(shooter: Model, origin: Vector3, direction: Vector3)\n\tconst params = RaycastParams.new()\n\tparams.ExcludeInstances = { shooter }\n\tparams.IncludeInstances = { Workspace:WaitForChild(\"FactoryFloor\") }\n\n\tconst startTime = os.clock()\n\tlocal position = origin\n\twhile os.clock() - startTime < MAX_LIFETIME do\n\t\tlocal elapsed = os.clock() - startTime\n\t\tlocal displacement = direction * SPEED * elapsed + Vector3.new(0, -0.5 * GRAVITY * elapsed * elapsed, 0)\n\t\tposition = origin + displacement\n\t\tif local hit = Workspace:Raycast(position, direction, params) then\n\t\t\tprint(`Projectile hit {hit.Instance.Name}`)\n\t\t\tbreak\n\t\tend\n\t\ttask.wait()\n\tend\nend\n\nconst playerShooters: { [Player]: Model } = {}\n\nconst function onPlayerAdded(player: Player)\n\tFIRE_EVENT.OnServerEvent:Connect(function(_, origin: Vector3, direction: Vector3)\n\t\tif local shooter = playerShooters[player] then\n\t\t\tlaunchProjectile(shooter, origin, direction)\n\t\tend\n\tend)\n\n\tconst function onCharacterAdded(character: Model)\n\t\tplayerShooters[player] = character\n\tend\n\n\tif local character = player.Character then\n\t\tonCharacterAdded(character)\n\tend\n\tplayer.CharacterAdded:Connect(onCharacterAdded)\nend\n\nPlayers.PlayerAdded:Connect(onPlayerAdded)\nfor _, player in Players:GetPlayers() do\n\ttask.spawn(onPlayerAdded, player)\nend\n```\n\nThis server script handles projectile firing for a tycoon factory game. It uses const for all never‑reassigned bindings, if local for nil checks on the raycast result and player character, and RaycastParams with ExcludeInstances/IncludeInstances for spatial filtering. The playerShooters table is updated on every CharacterAdded so the system keeps working after respawns.", "system": "You are an expert Roblox developer. You write modern, strictly typed Luau that uses current (2026) language features and Roblox APIs.", "id": "000002-d8d3", "meta": {"task_kind": "write", "script_kind": "Script (server, in ServerScriptService)", "domain": "projectile_arc", "theme": "tycoon factory", "complexity": "small", "features": ["const", "if_local", "spatial_filters"], "formatted": false, "repairs": 0, "model": "standard", "temperature": 0.3, "provider": "None", "tools": {"stylua": "stylua 2.5.2", "luau-lsp": "1.70.1", "luau-compile": "present"}, "generated_at": "2026-10-07T06:33:13Z"}}
{"instruction": "Create a server script in ServerScriptService that saves and loads coins per player for a racing league, using const.", "input": "", "output": "```luau\n--!strict\nconst Players = game:GetService(\"Players\")\nconst DataStoreService = game:GetService(\"DataStoreService\")\nconst ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\n\nconst COINS_DATASTORE_NAME = \"RacingLeagueCoins_v1\"\nconst MAX_ATTEMPTS = 4\nconst BASE_DELAY = 1\n\nconst coinStore = DataStoreService:GetDataStore(COINS_DATASTORE_NAME)\nconst coinEvent = ReplicatedStorage:WaitForChild(\"CoinUpdateEvent\") :: RemoteEvent\n\nconst coinsByPlayer: { [Player]: number } = {}\n\nconst function savePlayerCoins(player: Player): ()\n\tif const coins = coinsByPlayer[player] then\n\t\tfor attempt = 1, MAX_ATTEMPTS do\n\t\t\tconst ok, err = pcall(function()\n\t\t\t\tcoinStore:SetAsync(`Player_{player}`, coins)\n\t\t\tend)\n\t\t\tif ok then\n\t\t\t\treturn\n\t\t\tend\n\t\t\twarn(`Save attempt {attempt} failed: {err}`)\n\t\t\ttask.wait(BASE_DELAY * 2 ^ (attempt - 1))\n\t\tend\n\tend\nend\n\nconst function loadPlayerCoins(player: Player): number?\n\tfor attempt = 1, MAX_ATTEMPTS do\n\t\tconst ok, result = pcall(function()\n\t\t\treturn coinStore:GetAsync(`Player_{player}`)\n\t\tend)\n\t\tif ok then\n\t\t\tif const stored = result then\n\t\t\t\treturn tonumber(stored) or 0\n\t\t\tend\n\t\t\treturn 0\n\t\tend\n\t\twarn(`Load attempt {attempt} failed: {result}`)\n\t\ttask.wait(BASE_DELAY * 2 ^ (attempt - 1))\n\tend\n\treturn nil\nend\n\nconst function onPlayerAdded(player: Player): ()\n\tconst coins = loadPlayerCoins(player) or 0\n\tcoinsByPlayer[player] = coins\nend\n\nconst function onPlayerRemoving(player: Player): ()\n\tsavePlayerCoins(player)\n\tcoinsByPlayer[player] = nil\nend\n\ncoinEvent.OnServerEvent:Connect(function(player: Player, action: string, amount: number): ()\n\tif action == \"AddCoins\" then\n\t\tif const current = coinsByPlayer[player] then\n\t\t\tconst newBalance = current + amount\n\t\t\tcoinsByPlayer[player] = newBalance\n\t\t\tcoinEvent:FireClient(player, \"BalanceUpdated\", newBalance)\n\t\tend\n\tend\nend)\n\nPlayers.PlayerAdded:Connect(onPlayerAdded)\nfor _, player in Players:GetPlayers() do\n\ttask.spawn(onPlayerAdded, player)\nend\nPlayers.PlayerRemoving:Connect(onPlayerRemoving)\n```\n\nThe script persists each player's coin balance in a DataStore, loading on join and saving on leave. It uses const for every binding that is never reassigned, if const for nil checks, and pcall with capped exponential backoff for robust DataStore access. A RemoteEvent exposes an AddCoins action, making the logic straightforward to unit test.", "system": "You are an expert Roblox developer. You write modern, strictly typed Luau that uses current (2026) language features and Roblox APIs.", "id": "000001-1af5", "meta": {"task_kind": "write", "script_kind": "Script (server, in ServerScriptService)", "domain": "player_data_coins", "theme": "racing league", "complexity": "medium", "features": ["const"], "formatted": false, "repairs": 1, "model": "standard", "temperature": 0.3, "provider": "None", "tools": {"stylua": "stylua 2.5.2", "luau-lsp": "1.70.1", "luau-compile": "present"}, "generated_at": "2026-10-07T06:33:50Z"}}
{"instruction": "Hey, I'm a beginner building a robot arena game. I need a LocalScript that goes in StarterPlayer > StarterPlayerScripts so players can click on robots to select them. It should fire a ray from the camera when they press a key (and also work on gamepads), and it should be robust if the arena parts aren't loaded yet.", "input": "", "output": "```luau\n--!strict\nconst Players = game:GetService(\"Players\")\nconst Workspace = game:GetService(\"Workspace\")\nconst ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\n\n-- Build input action system\nconst context = Instance.new(\"InputContext\")\ncontext.Name = \"RobotArenaContext\"\ncontext.Parent = ReplicatedStorage\n\nconst selectAction = Instance.new(\"InputAction\")\nselectAction.Name = \"SelectRobot\"\nselectAction.Type = Enum.InputActionType.Bool\nselectAction.Parent = context\n\nconst keyboardBind = Instance.new(\"InputBinding\")\nkeyboardBind.KeyCode = Enum.KeyCode.LeftControl\nkeyboardBind.Parent = selectAction\n\nconst gamepadBind = Instance.new(\"InputBinding\")\ngamepadBind.KeyCode = Enum.KeyCode.ButtonL3\ngamepadBind.Parent = selectAction\n\nlocal function selectRobot()\n\tconst player = Players.LocalPlayer\n\tif local character = player.Character then\n\t\tif local arena = Workspace:WaitForChild(\"Arena\") then\n\t\t\tconst params = RaycastParams.new()\n\t\t\tparams.IncludeInstances = { arena }\n\t\t\tparams.ExcludeInstances = { character }\n\t\t\tif local camera = Workspace.CurrentCamera then\n\t\t\t\tconst mouse = player:GetMouse()\n\t\t\t\tconst ray = camera:ScreenPointToRay(mouse.X, mouse.Y)\n\t\t\t\tif local hit = Workspace:Raycast(ray.Origin, ray.Direction, params) then\n\t\t\t\t\tif local robot = hit.Instance:FindFirstAncestorOfClass(\"Model\") then\n\t\t\t\t\t\tprint(`Selected robot {robot.Name}`)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\nend\n\nselectAction.Pressed:Connect(selectRobot)\n```\n\nThis LocalScript creates an InputAction with keyboard and gamepad bindings that triggers a raycast from the camera through the mouse. It uses RaycastParams with IncludeInstances and ExcludeInstances to filter the arena and the player's character, and it waits for the arena to load before casting. The if local constructs safely handle nil values for the character, arena, camera, raycast hit, and robot ancestor.", "system": "You are an expert Roblox developer. You write modern, strictly typed Luau that uses current (2026) language features and Roblox APIs.", "id": "000007-e75c", "meta": {"task_kind": "write", "script_kind": "LocalScript (client)", "domain": "click_to_move", "theme": "robot arena", "complexity": "small", "features": ["if_local", "spatial_filters", "ias"], "formatted": false, "repairs": 1, "model": "standard", "temperature": 0.3, "provider": "None", "tools": {"stylua": "stylua 2.5.2", "luau-lsp": "1.70.1", "luau-compile": "present"}, "generated_at": "2026-10-07T06:39:10Z"}}
{"instruction": "Hey, I'm a beginner building a magic school game and I need a ModuleScript that handles grenade explosions. It should damage players within a radius and print warnings when something unexpected happens. The script should live in ReplicatedStorage and be easy to use.", "input": "", "output": "```luau\n--!strict\nconst Players = game:GetService(\"Players\")\nconst Workspace = game:GetService(\"Workspace\")\nconst Debris = game:GetService(\"Debris\")\n\nexport type ExplosionOptions = {\n    radius: number,\n    damage: number,\n    ignoreList: { Instance }?,\n}\n\nconst module = {}\n\nconst function logWarning(message: string)\n    warn(`[Grenade] {message}`)\nend\n\nconst function applyDamageToHumanoid(humanoid: Humanoid, damage: number)\n    if humanoid.Health > 0 then\n        humanoid:TakeDamage(damage)\n    end\nend\n\nfunction module.Detonate(position: Vector3, options: ExplosionOptions)\n    const radius = options.radius or 20\n    const damage = options.damage or 50\n    const ignoreList = options.ignoreList or {}\n\n    if radius <= 0 then\n        logWarning(\"Radius must be positive\")\n        return\n    end\n\n    if damage <= 0 then\n        logWarning(\"Damage must be positive\")\n        return\n    end\n\n    const params = OverlapParams.new()\n    params.ExcludeInstances = ignoreList\n\n    const parts = Workspace:GetPartBoundsInRadius(position, radius, params)\n\n    if #parts == 0 then\n        logWarning(\"No parts found in explosion radius\")\n        return\n    end\n\n    const damaged = {}\n\n    for _, part in parts do\n        if const humanoid = part:FindFirstAncestorWhichIsA(\"Humanoid\") :: Humanoid? then\n            const character = humanoid.Parent\n            if const player = Players:GetPlayerFromCharacter(character :: Model) then\n                if not damaged[player] then\n                    damaged[player] = true\n                    applyDamageToHumanoid(humanoid, damage)\n                end\n            else\n                applyDamageToHumanoid(humanoid, damage)\n            end\n        end\n    end\n\n    -- Visual effect\n    const explosionPart = Instance.new(\"Part\")\n    explosionPart.Name = \"ExplosionEffect\"\n    explosionPart.Material = Enum.Material.Neon\n    explosionPart.BrickColor = BrickColor.new(\"Bright orange\")\n    explosionPart.Shape = Enum.PartType.Ball\n    explosionPart.Size = Vector3.new(radius * 2, radius * 2, radius * 2)\n    explosionPart.CFrame = CFrame.new(position)\n    explosionPart.Anchored = true\n    explosionPart.CanCollide = false\n    explosionPart.Parent = Workspace\n\n    Debris:AddItem(explosionPart, 0.5)\nend\n\nreturn module\n```\n\nThis ModuleScript exports a Detonate function that creates an explosion effect, damages players in radius, and logs warnings for unexpected conditions. It uses const for every binding that is never reassigned and if const to safely handle optional values, while OverlapParams with ExcludeInstances provides efficient spatial filtering.", "system": "You are an expert Roblox developer. You write modern, strictly typed Luau that uses current (2026) language features and Roblox APIs.", "id": "000003-b5ad", "meta": {"task_kind": "write", "script_kind": "ModuleScript", "domain": "grenade_blast", "theme": "school of magic", "complexity": "medium", "features": ["const", "if_const", "spatial_filters"], "formatted": false, "repairs": 1, "model": "standard", "temperature": 0.3, "provider": "None", "tools": {"stylua": "stylua 2.5.2", "luau-lsp": "1.70.1", "luau-compile": "present"}, "generated_at": "2026-10-07T06:40:10Z"}}
{"instruction": "Write a LocalScript that lives in StarterPlayerScripts. It should provide click-to-interact functionality for a snowy mountain resort game. When the player presses the left mouse button, the script must cast a ray from the camera through the mouse position and check for a hit within a configurable distance. The raycast should be filtered to only consider objects located in a specific map folder and should exclude the player's own character. Only objects with a particular tag should be considered interactable. The script must ignore input when the game is processing it (for example, GUI clicks) and must not react to other input types or states. Include configurable tuning values at the top of the file for the maximum interaction distance, the interaction tag, and the map folder name. Handle edge cases such as the camera not being available, the map folder missing, and the player's character not yet loaded. Ensure the script is robust and does not produce errors under these conditions.", "input": "", "output": "```luau\n--!strict\nconst Players = game:GetService(\"Players\")\nconst Workspace = game:GetService(\"Workspace\")\nconst UserInputService = game:GetService(\"UserInputService\")\n\nconst MAX_INTERACTION_DISTANCE = 100\nconst INTERACTION_TAG = \"SkiLift\"\nconst MAP_FOLDER_NAME = \"Map\"\n\nconst player = Players.LocalPlayer\n\nconst mapFolder = Workspace:FindFirstChild(MAP_FOLDER_NAME)\nif not mapFolder then\n\twarn(\"Map folder not found\")\n\treturn\nend\n\nconst params = RaycastParams.new()\nparams.IncludeInstances = {mapFolder}\n\nconst function onInputBegan(input: InputObject, gameProcessed: boolean)\n\tif gameProcessed then\n\t\treturn\n\tend\n\tif input.UserInputState ~= Enum.UserInputState.Begin then\n\t\treturn\n\tend\n\tif input.UserInputType ~= Enum.UserInputType.MouseButton1 then\n\t\treturn\n\tend\n\tconst camera = Workspace.CurrentCamera\n\tif not camera then\n\t\treturn\n\tend\n\tconst character = player.Character\n\tconst excludeInstances: {Instance} = if character then {character} else {}\n\tparams.ExcludeInstances = excludeInstances\n\tconst mousePosition = UserInputService:GetMouseLocation()\n\tconst ray = camera:ScreenPointToRay(mousePosition.X, mousePosition.Y)\n\tif local hitResult = Workspace:Raycast(ray.Origin, ray.Direction * MAX_INTERACTION_DISTANCE, params) then\n\t\tif local hitInstance = hitResult.Instance then\n\t\t\tif hitInstance:HasTag(INTERACTION_TAG) then\n\t\t\t\tprint(`Interacted with {hitInstance.Name}`)\n\t\t\tend\n\t\tend\n\tend\nend\n\nUserInputService.InputBegan:Connect(onInputBegan)\n```\n\nThis LocalScript enables players to interact with tagged objects in the snowy mountain resort by clicking. It uses RaycastParams with IncludeInstances and ExcludeInstances to filter the raycast to the map folder and exclude the player's character. All bindings that are never reassigned are declared with const, including configuration values and intermediate results, improving correctness.", "system": "You are an expert Roblox developer. You write modern, strictly typed Luau that uses current (2026) language features and Roblox APIs.", "id": "000011-6c37", "meta": {"task_kind": "write", "script_kind": "LocalScript (client)", "domain": "click_to_move", "theme": "snowy mountain resort", "complexity": "small", "features": ["const", "spatial_filters"], "formatted": false, "repairs": 1, "model": "standard", "temperature": 0.3, "provider": "None", "tools": {"stylua": "stylua 2.5.2", "luau-lsp": "1.70.1", "luau-compile": "present"}, "generated_at": "2026-10-07T06:40:55Z"}}
{"instruction": "Hey, I'm building a battle royale game and need a server script in ServerScriptService that tracks quests for each player. It should store progress and rewards in a DataStore, and keep working even after the player respawns. I want to use `const` for everything that doesn't change, and wrap every DataStore call in `pcall` with capped exponential backoff. Can you help me write it?", "input": "", "output": "```luau\n--!strict\nconst Players = game:GetService(\"Players\")\nconst DataStoreService = game:GetService(\"DataStoreService\")\nconst ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\n\nconst QUEST_STORE_NAME = \"QuestData_v1\"\nconst MAX_ATTEMPTS = 4\nconst BASE_DELAY = 1\n\nconst questStore = DataStoreService:GetDataStore(QUEST_STORE_NAME)\n\nconst QUEST_TEMPLATES = {\n    [\"kill10\"] = { reward = 100, target = 10 },\n    [\"collect5\"] = { reward = 50, target = 5 },\n}\n\ntype PlayerQuestData = {\n    quests: { [string]: { progress: number, completed: boolean } },\n    coins: number,\n}\n\nlocal playerData: { [number]: PlayerQuestData } = {}\n\nconst questUpdateEvent = Instance.new(\"RemoteEvent\")\nquestUpdateEvent.Name = \"QuestUpdate\"\nquestUpdateEvent.Parent = ReplicatedStorage\n\nconst function loadPlayerData(userId: number): PlayerQuestData?\n    for attempt = 1, MAX_ATTEMPTS do\n        local ok, result = pcall(function()\n            return questStore:GetAsync(`Player_{userId}`)\n        end)\n        if ok then\n            if local data = result then\n                return data\n            end\n            return { quests = {}, coins = 0 }\n        end\n        warn(`DataStore load failed (attempt {attempt}/{MAX_ATTEMPTS}): {result}`)\n        task.wait(BASE_DELAY * 2 ^ (attempt - 1))\n    end\n    return nil\nend\n\nconst function savePlayerData(userId: number, data: PlayerQuestData): boolean\n    for attempt = 1, MAX_ATTEMPTS do\n        local ok, result = pcall(function()\n            questStore:SetAsync(`Player_{userId}`, data)\n            return true\n        end)\n        if ok then\n            return result\n        end\n        warn(`DataStore save failed (attempt {attempt}/{MAX_ATTEMPTS}): {result}`)\n        task.wait(BASE_DELAY * 2 ^ (attempt - 1))\n    end\n    return false\nend\n\nlocal function onPlayerAdded(player: Player)\n    const data = loadPlayerData(player.UserId) or { quests = {}, coins = 0 }\n    playerData[player.UserId] = data\n\n    local function onQuestUpdate(player: Player, requestedQuest: string, amount: number)\n        const questData = playerData[player.UserId]\n        if not questData then\n            return\n        end\n        local quest = questData.quests[requestedQuest]\n        if not quest then\n            quest = { progress = 0, completed = false }\n            questData.quests[requestedQuest] = quest\n        end\n        if quest.completed then\n            return\n        end\n        quest.progress += amount\n        const template = QUEST_TEMPLATES[requestedQuest]\n        if template and quest.progress >= template.target then\n            quest.completed = true\n            questData.coins += template.reward\n            questUpdateEvent:FireClient(player, \"QuestCompleted\", requestedQuest, template.reward)\n        end\n    end\n\n    questUpdateEvent.OnServerEvent:Connect(onQuestUpdate)\nend\n\nlocal function onPlayerRemoving(player: Player)\n    local data = playerData[player.UserId]\n    if data then\n        savePlayerData(player.UserId, data)\n        playerData[player.UserId] = nil\n    end\nend\n\nfor _, player in Players:GetPlayers() do\n    task.spawn(onPlayerAdded, player)\nend\n\nPlayers.PlayerAdded:Connect(onPlayerAdded)\nPlayers.PlayerRemoving:Connect(onPlayerRemoving)\n```\n\nThe script is a server-side quest tracker for a battle royale game. It uses `const` for all immutable bindings and wraps every DataStore call in `pcall` with capped exponential backoff. Player data is kept in memory and saved on leave, so progress persists across respawns. The remote event callback now correctly accepts the player as its first argument.", "system": "You are an expert Roblox developer. You write modern, strictly typed Luau that uses current (2026) language features and Roblox APIs.", "id": "000015-09b8", "meta": {"task_kind": "write", "script_kind": "Script (server, in ServerScriptService)", "domain": "quest_tracker", "theme": "battle royale", "complexity": "medium", "features": ["const", "datastore"], "formatted": false, "repairs": 1, "model": "standard", "temperature": 0.3, "provider": "None", "tools": {"stylua": "stylua 2.5.2", "luau-lsp": "1.70.1", "luau-compile": "present"}, "generated_at": "2026-10-07T06:41:05Z"}}
{"instruction": "Refactor this ServerScriptService script to use const, if local, if local in if-expression, and ExcludeInstances/IncludeInstances.\n```lua\nlocal Players = game:GetService(\"Players\")\nlocal Workspace = game:GetService(\"Workspace\")\nlocal HAZARD_NAME = \"KillBrick\"\nlocal DAMAGE = 25\nlocal DEBOUNCE = 1.5\nlocal lastHits = {}\n\nlocal function onHazardTouch(part)\n    local character = part.Parent\n    local player = Players:GetPlayerFromCharacter(character)\n    if player then\n        if not lastHits[player] or tick() - lastHits[player] > DEBOUNCE then\n            lastHits[player] = tick()\n            local humanoid = character:FindFirstChild(\"Humanoid\")\n            if humanoid then\n                humanoid.Health = humanoid.Health - DAMAGE\n            end\n        end\n    end\nend\n\nlocal hazard = Workspace:FindFirstChild(HAZARD_NAME)\nif hazard then\n    hazard.Touched:connect(onHazardTouch)\nelse\n    warn(\"Hazard part not found\")\nend\n\n-- Check zone with raycast\nlocal params = RaycastParams.new()\nparams.FilterDescendantsInstances = { Workspace:FindFirstChild(\"Map\") }\nparams.FilterType = Enum(raycastFilterType.Include)\nwait(2)\nlocal result = Workspace:Raycast(Vector3.new(0, 10, 0), Vector3.new(0, 0, 0), params)\nif result then\n    print(\"Raycast hit:\", result.Instance.Name)\nend\n```", "input": "", "output": "```luau\n--!strict\nconst Players = game:GetService(\"Players\")\nconst Workspace = game:GetService(\"Workspace\")\n\nconst HAZARD_NAME = \"KillBrick\"\nconst DAMAGE = 30\nconst DEBOUNCE = 1.5\n\nconst lastHits: { [Player]: number } = {}\n\nconst function onHazardTouch(part: BasePart)\n\tif local model = part:FindFirstAncestorOfClass(\"Model\") then\n\t\tif local player = Players:GetPlayerFromCharacter(model) then\n\t\t\tconst now = os.clock()\n\t\t\tif local last = lastHits[player] then\n\t\t\t\tif now - last < DEBOUNCE then\n\t\t\t\t\treturn\n\t\t\t\tend\n\t\t\tend\n\t\t\tlastHits[player] = now\n\t\t\tif local humanoid = model:FindFirstChildOfClass(\"Humanoid\") then\n\t\t\t\thumanoid.Health -= DAMAGE\n\t\t\tend\n\t\tend\n\tend\nend\n\nconst part = Instance.new(\"Part\")\npart.Name = HAZARD_NAME\npart.BrickColor = BrickColor.new(\"Dark red\")\npart.Material = Enum.Material.Neon\npart.Size = Vector3.new(5, 1, 5)\npart.Position = Vector3.new(0, 10, 0)\npart.Anchored = true\npart.Parent = Workspace\npart.Touched:Connect(onHazardTouch)\n\nif local zone = Workspace:FindFirstChildOfClass(\"BasePart\", \"HazardZone\") then\n\tconst params = OverlapParams.new()\n\tparams.IncludeInstances = { zone }\n\tconst parts = Workspace:GetPartBoundsInBox(zone.CFrame, zone.Size, params)\n\tprint(`Zone contains {#parts} parts`)\nelse\n\twarn(\"HazardZone missing\")\nend\n\nconst zoneStatus = if local z = Workspace:FindFirstChildOfClass(\"BasePart\", \"HazardZone\") then `Zone at {z.Position}` else \"No zone\"\nprint(zoneStatus)\n```\n\nThis server script spawns a kill brick that damages players on contact while respecting a debounce window. It uses const for every binding, if local for single-value nil checks, a binding if-expression for zone status, and the modern IncludeInstances filter on OverlapParams for spatial queries. Warnings are logged when expected parts are absent.", "system": "You are an expert Roblox developer. You write modern, strictly typed Luau that uses current (2026) language features and Roblox APIs.", "id": "000012-14fc", "meta": {"task_kind": "refactor", "script_kind": "Script (server, in ServerScriptService)", "domain": "kill_bricks", "theme": "airship fleet", "complexity": "small", "features": ["const", "if_local", "if_local_expr", "spatial_filters"], "formatted": false, "repairs": 1, "model": "standard", "temperature": 0.3, "provider": "None", "tools": {"stylua": "stylua 2.5.2", "luau-lsp": "1.70.1", "luau-compile": "present"}, "generated_at": "2026-10-07T06:41:58Z"}}
{"instruction": "I need a ModuleScript that implements a per-player rate limiter for remote events in a superhero city game. The module should provide a function to create a limiter with configurable max requests and time window, track each player's request timestamps, and automatically prune old entries. It must log useful warnings when rate limits are exceeded, when invalid arguments are passed, or when unexpected state is detected. All bindings that are never reassigned must be declared with const, including services, literal constants, and any intermediate results.\n\nThe ModuleScript should be placed in ServerScriptService and return a table with a create method. It must handle player removal to clean up state, use task.spawn and task.wait for periodic cleanup, and follow modern Luau conventions such as const, if const, and PascalCase APIs. The code should be self-contained, strictly typed, and around 140-240 lines.", "input": "", "output": "```luau\n--!strict\n-- ModuleScript: RateLimiter\n-- Provides per-player rate limiting for remote events in a superhero city game.\n-- Use create() to obtain a limiter instance.\n\nconst Players = game:GetService(\"Players\")\n\nconst DEFAULT_MAX_REQUESTS = 5\nconst DEFAULT_WINDOW = 5\nconst CLEANUP_INTERVAL = 30\nconst WARNING_COOLDOWN = 10\n\nexport type RateLimitState = {\n\tmaxRequests: number,\n\twindow: number,\n\trequests: { number },\n\tlastCleanup: number,\n}\n\nexport type RateLimiter = {\n\tcheck: (player: Player, action: string) -> boolean,\n\treset: (player: Player) -> (),\n\tdestroy: () -> (),\n\tgetRemaining: (player: Player) -> number,\n\tsetLimits: (max: number?, window: number?) -> (),\n\tclearAll: () -> (),\n}\n\nconst function createRateLimiter(maxRequests: number?, window: number?): RateLimiter\n\tconst config = {\n\t\tmaxRequests = maxRequests or DEFAULT_MAX_REQUESTS,\n\t\twindow = window or DEFAULT_WINDOW,\n\t}\n\tlocal state: { [Player]: RateLimitState } = {}\n\tlocal lastWarning: { [Player]: number } = {}\n\tlocal cleanupHandle: thread? = nil\n\n\tconst function performCleanup()\n\t\tconst now = os.clock()\n\t\tfor player, limitState in state do\n\t\t\tif now - limitState.lastCleanup > CLEANUP_INTERVAL then\n\t\t\t\tconst valid: { number } = {}\n\t\t\t\tfor _, timestamp in limitState.requests do\n\t\t\t\t\tif now - timestamp <= limitState.window then\n\t\t\t\t\t\ttable.insert(valid, timestamp)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tlimitState.requests = valid\n\t\t\t\tlimitState.lastCleanup = now\n\t\t\tend\n\t\tend\n\tend\n\n\tconst function startCleanup()\n\t\tif cleanupHandle then return end\n\t\tcleanupHandle = task.spawn(function()\n\t\t\twhile true do\n\t\t\t\ttask.wait(CLEANUP_INTERVAL)\n\t\t\t\tperformCleanup()\n\t\t\tend\n\t\tend)\n\tend\n\n\tconst function check(player: Player, action: string): boolean\n\t\tconst now = os.clock()\n\t\tif typeof(player) ~= \"Player\" then\n\t\t\twarn(\"RateLimiter.check received non-Player instance\")\n\t\t\treturn false\n\t\tend\n\t\tif typeof(action) ~= \"string\" then\n\t\t\twarn(\"RateLimiter.check received non-string action\")\n\t\t\treturn false\n\t\tend\n\t\tif const limitState = state[player] then\n\t\t\tconst valid: { number } = {}\n\t\t\tfor _, timestamp in limitState.requests do\n\t\t\t\tif now - timestamp <= limitState.window then\n\t\t\t\t\ttable.insert(valid, timestamp)\n\t\t\t\tend\n\t\t\tend\n\t\t\tlimitState.requests = valid\n\t\t\tif #limitState.requests >= limitState.maxRequests then\n\t\t\t\tif now - (lastWarning[player] or 0) > WARNING_COOLDOWN then\n\t\t\t\t\twarn(`Rate limit exceeded for {player.Name} on {action}`)\n\t\t\t\t\tlastWarning[player] = now\n\t\t\t\tend\n\t\t\t\treturn false\n\t\t\tend\n\t\t\ttable.insert(limitState.requests, now)\n\t\t\treturn true\n\t\telse\n\t\t\tstate[player] = {\n\t\t\t\tmaxRequests = config.maxRequests,\n\t\t\t\twindow = config.window,\n\t\t\t\trequests = { now },\n\t\t\t\tlastCleanup = now,\n\t\t\t}\n\t\t\treturn true\n\t\tend\n\tend\n\n\tconst function reset(player: Player)\n\t\tif typeof(player) ~= \"Player\" then\n\t\t\twarn(\"RateLimiter.reset received non-Player instance\")\n\t\t\treturn\n\t\tend\n\t\tstate[player] = nil\n\t\tlastWarning[player] = nil\n\tend\n\n\tconst function getRemaining(player: Player): number\n\t\tconst now = os.clock()\n\t\tif const limitState = state[player] then\n\t\t\tlocal count = 0\n\t\t\tfor _, timestamp in limitState.requests do\n\t\t\t\tif now - timestamp <= limitState.window then\n\t\t\t\t\tcount += 1\n\t\t\t\tend\n\t\t\tend\n\t\t\treturn math.max(0, limitState.maxRequests - count)\n\t\tend\n\t\treturn config.maxRequests\n\tend\n\n\tconst function setLimits(max: number?, window: number?)\n\t\tif max and max > 0 then\n\t\t\tconfig.maxRequests = max\n\t\telse\n\t\t\twarn(\"RateLimiter.setLimits received invalid max value\")\n\t\tend\n\t\tif window and window > 0 then\n\t\t\tconfig.window = window\n\t\telse\n\t\t\twarn(\"RateLimiter.setLimits received invalid window value\")\n\t\tend\n\tend\n\n\tconst function clearAll()\n\t\tstate = {}\n\t\tlastWarning = {}\n\tend\n\n\tconst function destroy()\n\t\tif cleanupHandle then\n\t\t\ttask.cancel(cleanupHandle)\n\t\t\tcleanupHandle = nil\n\t\tend\n\t\tstate = {}\n\t\tlastWarning = {}\n\tend\n\n\tconst playerRemovingConnection = Players.PlayerRemoving:Connect(function(player: Player)\n\t\treset(player)\n\tend)\n\n\tstartCleanup()\n\n\treturn {\n\t\tcheck = check,\n\t\treset = reset,\n\t\tdestroy = destroy,\n\t\tgetRemaining = getRemaining,\n\t\tsetLimits = setLimits,\n\t\tclearAll = clearAll,\n\t}\nend\n\nreturn {\n\tcreate = createRateLimiter,\n}\n```\n\nThis ModuleScript provides a per-player rate limiter with configurable limits, automatic cleanup, and warnings. It uses const for all never-reassigned bindings, if const for nil-checks, and task.* for scheduling. The design ensures safe cleanup on player removal and offers runtime adjustment of limits.", "system": "You are an expert Roblox developer. You write modern, strictly typed Luau that uses current (2026) language features and Roblox APIs.", "id": "000001-c94a", "meta": {"task_kind": "write", "script_kind": "ModuleScript", "domain": "rate_limiter", "theme": "superhero city", "complexity": "large", "features": ["const"], "formatted": false, "repairs": 0, "model": "standard", "temperature": 0.3, "provider": "None", "tools": {"stylua": "stylua 2.5.2", "luau-lsp": "1.70.1", "luau-compile": "present"}, "generated_at": "2026-10-07T06:42:15Z"}}
{"instruction": "Hey, I'm making a medieval fantasy game and I need a ModuleScript in ReplicatedStorage that manages sounds. It should play sounds, pool them, and clean up when a player leaves. I'm a beginner, so keep it simple.", "input": "", "output": "```luau\n--!strict\nconst Players = game:GetService(\"Players\")\nconst ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\n\nconst MAX_POOL_SIZE = 10\nconst DEFAULT_VOLUME = 1\nconst SOUND_FOLDER = ReplicatedStorage:WaitForChild(\"Sounds\") :: Folder\n\nconst SoundManager = {}\n\nconst activeSounds: { [Player]: { Sound } } = {}\nconst pool: { Sound } = {}\n\nconst function createSoundInstance(name: string): Sound\n\tconst sound = Instance.new(\"Sound\")\n\tsound.Name = name\n\tsound.Volume = DEFAULT_VOLUME\n\treturn sound\nend\n\nconst function getSoundFromPool(name: string): Sound?\n\tfor _, sound in pool do\n\t\tif sound.Name == name and not sound.IsPlaying then\n\t\t\treturn sound\n\t\tend\n\tend\n\treturn nil\nend\n\nconst function returnToPool(sound: Sound)\n\tif #pool < MAX_POOL_SIZE then\n\t\ttable.insert(pool, sound)\n\telse\n\t\tsound:Destroy()\n\tend\nend\n\nfunction SoundManager.PlaySound(player: Player, soundName: string, volume: number?): Sound?\n\tconst sound = getSoundFromPool(soundName) or createSoundInstance(soundName)\n\tsound.Volume = volume or DEFAULT_VOLUME\n\tsound:Play()\n\tif not activeSounds[player] then\n\t\tactiveSounds[player] = {}\n\tend\n\ttable.insert(activeSounds[player], sound)\n\treturn sound\nend\n\nfunction SoundManager.StopSound(player: Player, sound: Sound)\n\tif sound.IsPlaying then\n\t\tsound:Stop()\n\tend\n\tconst list = activeSounds[player]\n\tif list then\n\t\tconst index = table.find(list, sound)\n\t\tif index then\n\t\t\ttable.remove(list, index)\n\t\tend\n\tend\n\treturnToPool(sound)\nend\n\nfunction SoundManager.StopAllSounds(player: Player)\n\tconst list = activeSounds[player]\n\tif list then\n\t\tfor _, sound in list do\n\t\t\tsound:Stop()\n\t\t\treturnToPool(sound)\n\t\tend\n\t\tactiveSounds[player] = {}\n\tend\nend\n\nconst function onPlayerRemoving(player: Player)\n\tSoundManager.StopAllSounds(player)\nend\n\nPlayers.PlayerRemoving:Connect(onPlayerRemoving)\n\nreturn SoundManager\n```\n\nThe module implements a pooled sound manager that plays and reuses Sound instances, and it automatically stops and recycles all sounds when a player leaves. It uses const for every binding that never changes, which makes the code more reliable and easier to read. The design keeps memory usage low by limiting the pool size and cleaning up on player removal.", "system": "You are an expert Roblox developer. You write modern, strictly typed Luau that uses current (2026) language features and Roblox APIs.", "id": "000023-260b", "meta": {"task_kind": "write", "script_kind": "ModuleScript", "domain": "sound_manager", "theme": "medieval fantasy", "complexity": "medium", "features": ["const"], "formatted": true, "repairs": 0, "model": "standard", "temperature": 0.3, "provider": "None", "tools": {"stylua": "stylua 2.5.2", "luau-lsp": "1.70.1", "luau-compile": "present"}, "generated_at": "2026-10-07T06:44:18Z"}}
{"instruction": "I need a ModuleScript called CharacterUtils to be placed in ReplicatedStorage. It should expose functions that safely read a player's character, humanoid, root part, and the player from a character. The functions must handle missing objects gracefully and log useful warnings whenever something unexpected happens.", "input": "", "output": "```luau\n--!strict\nexport type CharacterUtils = {\n    GetCharacter: (player: Player) -> Model?,\n    GetHumanoid: (model: Model) -> Humanoid?,\n    GetRootPart: (model: Model) -> BasePart?,\n    GetPlayerFromCharacter: (model: Model) -> Player?,\n    WaitForCharacter: (player: Player, timeout: number?) -> Model?,\n}\n\nconst Players = game:GetService(\"Players\")\nconst DEFAULT_TIMEOUT = 10\n\nconst function GetCharacter(player: Player): Model?\n    if local character = player.Character then\n        return character\n    end\n    warn(`Player {player.Name} has no character`)\n    return nil\nend\n\nconst function GetHumanoid(model: Model): Humanoid?\n    if local humanoid = model:FindFirstChildOfClass(\"Humanoid\") then\n        return humanoid\n    end\n    warn(`Model {model.Name} has no Humanoid`)\n    return nil\nend\n\nconst function GetRootPart(model: Model): BasePart?\n    if local humanoid = GetHumanoid(model) then\n        if local rootPart = humanoid.RootPart then\n            return rootPart\n        end\n        warn(`Humanoid in model {model.Name} has no RootPart`)\n        return nil\n    end\n    -- fallback: look for HumanoidRootPart by name\n    if local rootPart = model:FindFirstChild(\"HumanoidRootPart\") then\n        if rootPart:IsA(\"BasePart\") then\n            return rootPart\n        end\n    end\n    warn(`Model {model.Name} has no root part`)\n    return nil\nend\n\nconst function GetPlayerFromCharacter(model: Model): Player?\n    if local player = Players:GetPlayerFromCharacter(model) then\n        return player\n    end\n    warn(`No player associated with model {model.Name}`)\n    return nil\nend\n\nconst function WaitForCharacter(player: Player, timeout: number?): Model?\n    const waitTime = timeout or DEFAULT_TIMEOUT\n    local elapsed = 0\n    while elapsed < waitTime do\n        if local character = player.Character then\n            return character\n        end\n        task.wait(0.1)\n        elapsed += 0.1\n    end\n    warn(`Timed out waiting for character of player {player.Name}`)\n    return nil\nend\n\nconst utils: CharacterUtils = {\n    GetCharacter = GetCharacter,\n    GetHumanoid = GetHumanoid,\n    GetRootPart = GetRootPart,\n    GetPlayerFromCharacter = GetPlayerFromCharacter,\n    WaitForCharacter = WaitForCharacter,\n}\n\nreturn utils\n```\n\nThe module exports a table of helper functions that safely retrieve a player's character, humanoid, root part, and associated player. It uses `const` for every binding that is never reassigned, including services, literal constants, and function results. `if local` is used for concise nil checks, and `warn` calls log unexpected conditions to aid debugging.", "system": "You are an expert Roblox developer. You write modern, strictly typed Luau that uses current (2026) language features and Roblox APIs.", "id": "000027-882b", "meta": {"task_kind": "write", "script_kind": "ModuleScript", "domain": "character_utils", "theme": "desert ruins", "complexity": "medium", "features": ["const"], "formatted": false, "repairs": 0, "model": "standard", "temperature": 0.3, "provider": "None", "tools": {"stylua": "stylua 2.5.2", "luau-lsp": "1.70.1", "luau-compile": "present"}, "generated_at": "2026-10-07T06:45:15Z"}}
{"instruction": "Write a LocalScript in StarterPlayerScripts for click-to-move on the parkour tower using const and ExcludeInstances/IncludeInstances, blocking exploit abuse.", "input": "", "output": "```luau\n--!strict\nconst Players = game:GetService(\"Players\")\nconst UserInputService = game:GetService(\"UserInputService\")\nconst ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\nconst Workspace = game:GetService(\"Workspace\")\n\nconst towerFolder = Workspace:WaitForChild(\"TowerParts\") :: Folder\nconst moveRemote = ReplicatedStorage:WaitForChild(\"RequestMove\") :: RemoteEvent\n\nconst localPlayer = Players.LocalPlayer\n\nconst params = RaycastParams.new()\nparams.IncludeInstances = { towerFolder }\n\nlocal debounce = false\n\nconst function onClick()\n    if debounce then\n        return\n    end\n    debounce = true\n    task.wait(0.2)\n    debounce = false\n\n    params.ExcludeInstances = if localPlayer.Character then { localPlayer.Character } else {}\n\n    if local camera = Workspace.CurrentCamera then\n        const mouseLocation = UserInputService:GetMouseLocation()\n        const ray = camera:ScreenPointToRay(mouseLocation.X, mouseLocation.Y)\n        if local result = Workspace:Raycast(ray.Origin, ray.Direction, params) then\n            moveRemote:FireServer(result.Position, result.Instance)\n        end\n    end\nend\n\nUserInputService.InputBegan:Connect(function(input, gameProcessed)\n    if gameProcessed then\n        return\n    end\n    if input.UserInputType == Enum.UserInputType.MouseButton1 and input.UserInputState == Enum.UserInputState.Begin then\n        onClick()\n    end\nend)\n```\n\nThis LocalScript handles click-to-move on the parkour tower by raycasting from the camera with IncludeInstances and ExcludeInstances to filter tower parts and ignore the player's character. It uses const for all immutable bindings and if local for nil-checks, and debounces clicks to prevent exploit abuse.", "system": "You are an expert Roblox developer. You write modern, strictly typed Luau that uses current (2026) language features and Roblox APIs.", "id": "000025-3b7c", "meta": {"task_kind": "write", "script_kind": "LocalScript (client)", "domain": "click_to_move", "theme": "obby/parkour tower", "complexity": "small", "features": ["const", "spatial_filters"], "formatted": false, "repairs": 1, "model": "standard", "temperature": 0.3, "provider": "None", "tools": {"stylua": "stylua 2.5.2", "luau-lsp": "1.70.1", "luau-compile": "present"}, "generated_at": "2026-10-07T06:46:08Z"}}
{"instruction": "Create a ModuleScript for a hitscan weapon in a sci-fi space station game. The module should export a function that creates a weapon instance capable of firing immediate raycasts, applying damage to whatever it hits, and cleaning up all associated connections when the player leaves. The weapon must support configurable damage, range, and fire rate. Handle cases where the player's character is not yet loaded and ensure the module does not leak resources.", "input": "", "output": "```luau\n--!strict\n\nconst Players = game:GetService(\"Players\")\nconst Workspace = game:GetService(\"Workspace\")\n\nexport type HitscanConfig = {\n    damage: number,\n    range: number,\n    fireRate: number,\n}\n\nexport type HitscanWeapon = {\n    fire: (self: HitscanWeapon, origin: Vector3, direction: Vector3) -> (),\n    cleanup: (self: HitscanWeapon) -> (),\n    connection: any?,\n    player: Player,\n    config: HitscanConfig,\n}\n\nconst mapFolder = Workspace:WaitForChild(\"StationMap\") :: Folder\nconst weaponsByPlayer = {} :: { [Player]: HitscanWeapon }\n\nconst function createHitscanWeapon(player: Player, config: HitscanConfig): HitscanWeapon\n    local weapon = {\n        player = player,\n        config = config,\n        connection = nil :: any?,\n        fire = function(self: HitscanWeapon, origin: Vector3, direction: Vector3)\n            const params = RaycastParams.new()\n            params.IncludeInstances = { mapFolder }\n            if local character = player.Character then\n                params.ExcludeInstances = { character }\n            else\n                params.ExcludeInstances = {}\n            end\n            const result = Workspace:Raycast(origin, direction, params)\n            if local hit = result then\n                if local humanoid = hit.Instance:FindFirstChildOfClass(\"Humanoid\") then\n                    humanoid:TakeDamage(config.damage)\n                end\n            end\n        end,\n        cleanup = function(self: HitscanWeapon)\n            if self.connection then\n                self.connection:Disconnect()\n                self.connection = nil\n            end\n            weaponsByPlayer[player] = nil\n        end,\n    }\n\n    weapon.connection = Players.PlayerRemoving:Connect(function(leftPlayer: Player)\n        if leftPlayer == player then\n            weapon:cleanup()\n        end\n    end)\n\n    weaponsByPlayer[player] = weapon\n\n    return weapon\nend\n\nreturn createHitscanWeapon\n```\n\nThe module implements a hitscan weapon factory using const for all immutable bindings, if local for nil-checks on raycast results, and RaycastParams with IncludeInstances/ExcludeInstances for spatial filtering. It cleans up connections when the player leaves using colon syntax for method calls.", "system": "You are an expert Roblox developer. You write modern, strictly typed Luau that uses current (2026) language features and Roblox APIs.", "id": "000038-bcb5", "meta": {"task_kind": "write", "script_kind": "ModuleScript", "domain": "hitscan_weapon", "theme": "sci-fi space station", "complexity": "medium", "features": ["const", "if_local", "spatial_filters"], "formatted": false, "repairs": 1, "model": "standard", "temperature": 0.3, "provider": "None", "tools": {"stylua": "stylua 2.5.2", "luau-lsp": "1.70.1", "luau-compile": "present"}, "generated_at": "2026-10-07T06:48:49Z"}}
{"instruction": "I need a ModuleScript called CharacterUtils that lives in ReplicatedStorage. It should provide helper functions to safely read a player's character, humanoid, and root part, handling cases where the character hasn't loaded yet. The module must work efficiently for many players at once without causing memory leaks, cleaning up connections when players leave. The setting is a post‑apocalyptic wasteland, so the helpers should be robust against missing parts and temporary nil returns.", "input": "", "output": "```luau\n--!strict\nexport type CharacterInfo = { model: Model, humanoid: Humanoid, root: BasePart }\n\nconst Players = game:GetService(\"Players\")\nconst MAX_WAIT_SECONDS = 10\nconst RETRY_DELAY = 0.5\n\nlocal playerEntries: { [Player]: { connection: RBXScriptConnection, cleanup: () -> () } } = {}\n\nlocal function cleanupPlayer(player: Player)\n\tif local entry = playerEntries[player] then\n\t\tentry.connection:Disconnect()\n\t\tentry.cleanup()\n\t\tplayerEntries[player] = nil\n\tend\nend\n\nPlayers.PlayerRemoving:Connect(cleanupPlayer)\n\nlocal function GetCharacterAsync(player: Player): Model?\n\tlocal character = player.Character\n\tif local model = character then\n\t\treturn model\n\tend\n\tlocal elapsed = 0.0\n\twhile elapsed < MAX_WAIT_SECONDS do\n\t\tconst maybeModel = player.Character\n\t\tif local model = maybeModel then\n\t\t\treturn model\n\t\tend\n\t\ttask.wait(RETRY_DELAY)\n\t\telapsed += RETRY_DELAY\n\tend\n\treturn nil\nend\n\nlocal function GetHumanoid(player: Player): Humanoid?\n\tconst model = GetCharacterAsync(player)\n\tif local char = model then\n\t\tif local humanoid = char:FindFirstChildOfClass(\"Humanoid\") :: Humanoid? then\n\t\t\treturn humanoid\n\t\tend\n\tend\n\treturn nil\nend\n\nlocal function GetRootPart(player: Player): BasePart?\n\tconst humanoid = GetHumanoid(player)\n\tif humanoid then\n\t\tconst root = if local part = humanoid.RootPart then part else nil\n\t\treturn root\n\tend\n\treturn nil\nend\n\nlocal function GetCharacterInfo(player: Player): CharacterInfo?\n\tconst model = GetCharacterAsync(player)\n\tif local char = model then\n\t\tif local humanoid = char:FindFirstChildOfClass(\"Humanoid\") :: Humanoid? then\n\t\t\tif local root = humanoid.RootPart then\n\t\t\t\treturn { model = char, humanoid = humanoid, root = root }\n\t\t\tend\n\t\tend\n\tend\n\treturn nil\nend\n\nlocal function WaitForRootPart(player: Player, timeout: number): BasePart?\n\tconst start = os.clock()\n\twhile os.clock() - start < timeout do\n\t\tconst root = GetRootPart(player)\n\t\tif local part = root then\n\t\t\treturn part\n\t\tend\n\t\ttask.wait(0.1)\n\tend\n\treturn nil\nend\n\nlocal function GetHealth(player: Player): number?\n\tconst humanoid = GetHumanoid(player)\n\tif local h = humanoid then\n\t\treturn h.Health\n\tend\n\treturn nil\nend\n\nlocal function IsAlive(player: Player): boolean\n\tconst health = GetHealth(player)\n\tif local value = health then\n\t\treturn value > 0\n\tend\n\treturn false\nend\n\nlocal function GetCharacterName(player: Player): string\n\tconst model = GetCharacterAsync(player)\n\tif local char = model then\n\t\treturn char.Name\n\tend\n\treturn \"Unknown\"\nend\n\nlocal function GetHumanoidMaxHealth(player: Player): number?\n\tconst humanoid = GetHumanoid(player)\n\tif local h = humanoid then\n\t\treturn h.MaxHealth\n\tend\n\treturn nil\nend\n\nlocal function GetHumanoidState(player: Player): Enum.HumanoidStateType?\n\tconst humanoid = GetHumanoid(player)\n\tif local h = humanoid then\n\t\treturn h:GetState()\n\tend\n\treturn nil\nend\n\nlocal function onPlayerAdded(player: Player)\n\tconst connection = player.CharacterAdded:Connect(function()\n\t\t-- Could warm up character data here\n\tend)\n\tplayerEntries[player] = {\n\t\tconnection = connection,\n\t\tcleanup = function()\n\t\t\t-- No extra resources to free\n\t\tend,\n\t}\nend\n\nPlayers.PlayerAdded:Connect(onPlayerAdded)\n\nfor _, player in Players:GetPlayers() do\n\ttask.spawn(onPlayerAdded, player)\nend\n\nreturn {\n\tGetCharacterAsync = GetCharacterAsync,\n\tGetHumanoid = GetHumanoid,\n\tGetRootPart = GetRootPart,\n\tGetCharacterInfo = GetCharacterInfo,\n\tWaitForRootPart = WaitForRootPart,\n\tGetHealth = GetHealth,\n\tIsAlive = IsAlive,\n\tGetCharacterName = GetCharacterName,\n\tGetHumanoidMaxHealth = GetHumanoidMaxHealth,\n\tGetHumanoidState = GetHumanoidState,\n}\n```\n\nThis module provides safe, async access to a player's character, humanoid, and root part. It uses `const` for services and constants, `if local` for nil checks, and an `if local` expression to retrieve the root part. Connections are tracked per player and disconnected on removal to prevent memory leaks. The `GetHumanoidState` function uses `GetState()` to avoid a type error, and all `FindFirstChildOfClass` calls are cast to the correct type.", "system": "You are an expert Roblox developer. You write modern, strictly typed Luau that uses current (2026) language features and Roblox APIs.", "id": "000037-43ce", "meta": {"task_kind": "write", "script_kind": "ModuleScript", "domain": "character_utils", "theme": "post-apocalyptic wasteland", "complexity": "large", "features": ["if_local", "if_local_expr"], "formatted": false, "repairs": 1, "model": "standard", "temperature": 0.3, "provider": "None", "tools": {"stylua": "stylua 2.5.2", "luau-lsp": "1.70.1", "luau-compile": "present"}, "generated_at": "2026-10-07T06:49:10Z"}}
{"instruction": "Modernize this LocalScript in StarterPlayerScripts for an underwater research lab vehicle: it reads WASD/gamepad input, computes throttle/steer/brake, and exposes a clean API for unit testing.\n```lua\nlocal UserInputService = game:GetService(\"UserInputService\")\nlocal RunService = game:GetService(\"RunService\")\n\nlocal MAX_SPEED = 50\nlocal TURN_RATE = 2\nlocal BRAKE_FORCE = 30\n\nlocal throttle = 0\nlocal steer = 0\nlocal brake = 0\n\nlocal function onInput(actionName, inputState, inputObject)\n\tif actionName == \"Throttle\" then\n\t\tif inputState == Enum.UserInputState.Begin then\n\t\t\tthrottle = 1\n\t\telseif inputState == Enum.UserInputState.End then\n\t\t\tthrottle = 0\n\t\tend\n\telseif actionName == \"Brake\" then\n\t\tif inputState == Enum.UserInputState.Begin then\n\t\t\tbrake = 1\n\t\telseif inputState == Enum.UserInputState.End then\n\t\t\tbrake = 0\n\t\tend\n\telseif actionName == \"SteerLeft\" then\n\t\tif inputState == Enum.UserInputState.Begin then\n\t\t\tsteer = -1\n\t\telseif inputState == Enum.UserInputState.End then\n\t\t\tsteer = 0\n\t\tend\n\telseif actionName == \"SteerRight\" then\n\t\tif inputState == Enum.UserInputState.Begin then\n\t\t\tsteer = 1\n\t\telseif inputState == Enum.UserInputState.End then\n\t\t\tsteer = 0\n\t\tend\n\tend\nend\n\nUserInputService.InputBegan:Connect(function(input, processed)\n\tif processed then return end\n\tif input.KeyCode == Enum.KeyCode.W then onInput(\"Throttle\", Enum.UserInputState.Begin, input) end\n\tif input.KeyCode == Enum.KeyCode.S then onInput(\"Brake\", Enum.UserInputState.Begin, input) end\n\tif input.KeyCode == Enum.KeyCode.A then onInput(\"SteerLeft\", Enum.UserInputState.Begin, input) end\n\tif input.KeyCode == Enum.KeyCode.D then onInput(\"SteerRight\", Enum.UserInputState.Begin, input) end\nend)\nUserInputService.InputEnded:Connect(function(input, processed)\n\tif processed then return end\n\tif input.KeyCode == Enum.KeyCode.W then onInput(\"Throttle\", Enum.UserInputState.End, input) end\n\tif input.KeyCode == Enum.KeyCode.S then onInput(\"Brake\", Enum.UserInputState.End, input) end\n\tif input.KeyCode == Enum.KeyCode.A then onInput(\"SteerLeft\", Enum.UserInputState.End, input) end\n\tif input.KeyCode == Enum.KeyCode.D then onInput(\"SteerRight\", Enum.UserInputState.End, input) end\nend)\n\nlocal function getInputs()\n\treturn { throttle = throttle, steer = steer, brake = brake }\nend\n\nreturn { getInputs = getInputs }\n```", "input": "", "output": "```luau\n--!strict\n-- SubmersibleInput.client.luau\n-- StarterPlayerScripts/SubmersibleInput.client.luau\n-- Driver input for the research submersible (throttle, steer, brake) using IAS.\n-- Designed for unit testing: pure logic is separated from InputAction wiring.\n\nexport type InputState = {\n\tthrottle: number, -- 0..1\n\tsteer: number, -- -1..1\n\tbrake: number, -- 0..1\n}\n\nexport type SubmersibleInput = {\n\tgetState: () -> InputState,\n\tdestroy: () -> (),\n}\n\nconst UserInputService = game:GetService(\"UserInputService\")\nconst ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\n\nconst MAX_SPEED = 50\nconst TURN_RATE = 2\nconst BRAKE_FORCE = 30\n\n-- Pure, testable logic --------------------------------------------------------\n\nlocal function clamp01(value: number): number\n\treturn math.clamp(value, 0, 1)\nend\n\nlocal function clamp11(value: number): number\n\treturn math.clamp(value, -1, 1)\nend\n\nlocal function createInputState(): InputState\n\treturn { throttle = 0, steer = 0, brake = 0 }\nend\n\nlocal function applyThrottle(state: InputState, value: number): ()\n\tstate.throttle = clamp01(value)\nend\n\nlocal function applyBrake(state: InputState, value: number): ()\n\tstate.brake = clamp01(value)\nend\n\nlocal function applySteer(state: InputState, value: number): ()\n\tstate.steer = clamp11(value)\nend\n\n-- IAS construction ------------------------------------------------------------\n\nlocal function buildInputContext(): InputContext\n\tconst context = Instance.new(\"InputContext\")\n\tcontext.Name = \"SubmersibleContext\"\n\tcontext.Priority = 100\n\tcontext.Sink = false\n\n\t-- Throttle (W / Gamepad RightTrigger)\n\tconst throttleAction = Instance.new(\"InputAction\")\n\tthrottleAction.Name = \"Throttle\"\n\tthrottleAction.Type = Enum.InputActionType.Bool\n\tthrottleAction.Parent = context\n\n\tconst throttleKeyboard = Instance.new(\"InputBinding\")\n\tthrottleKeyboard.KeyCode = Enum.KeyCode.W\n\tthrottleKeyboard.Parent = throttleAction\n\n\tconst throttleGamepad = Instance.new(\"InputBinding\")\n\tthrottleGamepad.KeyCode = Enum.KeyCode.ButtonR2\n\tthrottleGamepad.Parent = throttleAction\n\n\t-- Brake (S / Gamepad LeftTrigger)\n\tconst brakeAction = Instance.new(\"InputAction\")\n\tbrakeAction.Name = \"Brake\"\n\tbrakeAction.Type = Enum.InputActionType.Bool\n\tbrakeAction.Parent = context\n\n\tconst brakeKeyboard = Instance.new(\"InputBinding\")\n\tbrakeKeyboard.KeyCode = Enum.KeyCode.S\n\tbrakeKeyboard.Parent = brakeAction\n\n\tconst brakeGamepad = Instance.new(\"InputBinding\")\n\tbrakeGamepad.KeyCode = Enum.KeyCode.ButtonL2\n\tbrakeGamepad.Parent = brakeAction\n\n\t-- Steer (A/D / Gamepad LeftThumbstick X)\n\tconst steerAction = Instance.new(\"InputAction\")\n\tsteerAction.Name = \"Steer\"\n\tsteerAction.Type = Enum.InputActionType.Direction1D\n\tsteerAction.Parent = context\n\n\tconst steerKeyboardLeft = Instance.new(\"InputBinding\")\n\tsteerKeyboardLeft.KeyCode = Enum.KeyCode.A\n\tsteerKeyboardLeft.Scale = -1\n\tsteerKeyboardLeft.Parent = steerAction\n\n\tconst steerKeyboardRight = Instance.new(\"InputBinding\")\n\tsteerKeyboardRight.KeyCode = Enum.KeyCode.D\n\tsteerKeyboardRight.Scale = 1\n\tsteerKeyboardRight.Parent = steerAction\n\n\tconst steerGamepad = Instance.new(\"InputBinding\")\n\tsteerGamepad.KeyCode = Enum.KeyCode.Thumbstick1\n\tsteerGamepad.Scale = 1\n\tsteerGamepad.Parent = steerAction\n\n\tcontext.Parent = ReplicatedStorage\n\treturn context\nend\n\n-- Public module ---------------------------------------------------------------\n\nlocal function createSubmersibleInput(): SubmersibleInput\n\tconst state = createInputState()\n\tconst context = buildInputContext()\n\n\tconst throttleAction = context:FindFirstChild(\"Throttle\") :: InputAction\n\tconst brakeAction = context:FindFirstChild(\"Brake\") :: InputAction\n\tconst steerAction = context:FindFirstChild(\"Steer\") :: InputAction\n\n\tthrottleAction.Pressed:Connect(function()\n\t\tapplyThrottle(state, 1)\n\tend)\n\tthrottleAction.Released:Connect(function()\n\t\tapplyThrottle(state, 0)\n\tend)\n\n\tbrakeAction.Pressed:Connect(function()\n\t\tapplyBrake(state, 1)\n\tend)\n\tbrakeAction.Released:Connect(function()\n\t\tapplyBrake(state, 0)\n\tend)\n\n\tsteerAction.StateChanged:Connect(function(value: number)\n\t\tapplySteer(state, value)\n\tend)\n\n\tlocal function getState(): InputState\n\t\treturn table.clone(state)\n\tend\n\n\tlocal function destroy(): ()\n\t\tcontext:Destroy()\n\tend\n\n\treturn {\n\t\tgetState = getState,\n\t\tdestroy = destroy,\n\t}\nend\n\n-- For direct require() in other client scripts\nconst submersibleInput = createSubmersibleInput()\n\nreturn submersibleInput\n```\n\nThe legacy script used UserInputService events with string action names and global mutable state. The rewrite adopts the Input Action System: an InputContext holds three InputActions (Throttle, Brake, Steer) each with keyboard and gamepad bindings. All immutable bindings are `const`; the mutable input state lives in a single table cloned on read. Pure helper functions (clamp01, clamp11, applyThrottle, etc.) are separated from IAS wiring so they can be unit-tested without Roblox services. The module returns a ready-to-use instance plus a destroy function for cleanup.", "system": "You are an expert Roblox developer. You write modern, strictly typed Luau that uses current (2026) language features and Roblox APIs.", "id": "000002-232c", "meta": {"task_kind": "refactor", "script_kind": "LocalScript (client)", "domain": "vehicle_controls", "theme": "underwater research lab", "complexity": "medium", "features": ["const", "ias"], "formatted": true, "repairs": 0, "model": "nvidia/nemotron-3-ultra-550b-a55b", "temperature": 0.2, "reasoning_effort": "low", "tools": {"stylua": "stylua 2.5.2", "luau-lsp": "1.70.1", "luau-compile": "present"}, "generated_at": "2026-10-07T06:49:22Z"}}
{"instruction": "Write a ModuleScript for a hitscan laser cannon in a robot arena that handles many players without memory leaks.", "input": "", "output": "```luau\n--!strict\nconst Players = game:GetService(\"Players\")\nconst Workspace = game:GetService(\"Workspace\")\nconst ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\n\nexport type WeaponConfig = {\n    damage: number,\n    range: number,\n    cooldown: number,\n}\n\nexport type HitResult = {\n    instance: Instance,\n    position: Vector3,\n    normal: Vector3,\n    distance: number,\n}\n\nconst DEFAULT_CONFIG: WeaponConfig = {\n    damage = 55,\n    range = 260,\n    cooldown = 0.3,\n}\n\nconst weaponFolder = Instance.new(\"Folder\")\nweaponFolder.Name = \"Weapons\"\nweaponFolder.Parent = ReplicatedStorage\n\nconst fireRemote = Instance.new(\"RemoteEvent\")\nfireRemote.Name = \"LaserCannonFire\"\nfireRemote.Parent = weaponFolder\n\nconst connections: { [Player]: any } = {}\n\nconst function onPlayerAdded(player: Player)\n    const connection = fireRemote.OnServerEvent:Connect(function(player: Player, origin: Vector3, direction: Vector3)\n        const config = DEFAULT_CONFIG\n        const now = os.clock()\n        const lastFire = player:GetAttribute(\"LastFire\") :: number?\n        if lastFire and now - lastFire < config.cooldown then\n            return\n        end\n        player:SetAttribute(\"LastFire\", now)\n\n        const params = RaycastParams.new()\n        params.ExcludeInstances = { player.Character or player } :: {Instance}\n\n        const result = Workspace:Raycast(origin, direction * config.range, params)\n        if local hit = result then\n            if local model = hit.Instance:FindFirstAncestorOfClass(\"Model\") then\n                if local humanoid = model:FindFirstChildOfClass(\"Humanoid\") then\n                    humanoid:TakeDamage(config.damage)\n                end\n            end\n            fireRemote:FireClient(player, {\n                instance = hit.Instance,\n                position = hit.Position,\n                normal = hit.Normal,\n                distance = hit.Distance,\n            })\n        end\n    end)\n    connections[player] = connection\nend\n\nconst function onPlayerRemoving(player: Player)\n    if local connection = connections[player] then\n        connection:Disconnect()\n        connections[player] = nil\n    end\nend\n\nPlayers.PlayerAdded:Connect(onPlayerAdded)\nPlayers.PlayerRemoving:Connect(onPlayerRemoving)\n\nfor _, player in Players:GetPlayers() do\n    task.spawn(onPlayerAdded, player)\nend\n\nconst function Destroy()\n    for player, connection in connections do\n        connection:Disconnect()\n        connections[player] = nil\n    end\nend\n\nreturn { Destroy = Destroy }\n```\n\nThis module creates a RemoteEvent for firing a hitscan laser, enforces per-player cooldown via attributes, and executes a raycast that excludes the shooter. It uses const for all immutable bindings and if local for nil checks, and it disconnects connections when players leave to prevent memory leaks.", "system": "You are an expert Roblox developer. You write modern, strictly typed Luau that uses current (2026) language features and Roblox APIs.", "id": "000041-ceaf", "meta": {"task_kind": "write", "script_kind": "ModuleScript", "domain": "hitscan_weapon", "theme": "robot arena", "complexity": "medium", "features": ["const"], "formatted": false, "repairs": 1, "model": "standard", "temperature": 0.3, "provider": "None", "tools": {"stylua": "stylua 2.5.2", "luau-lsp": "1.70.1", "luau-compile": "present"}, "generated_at": "2026-10-07T06:50:48Z"}}
{"instruction": "I need a client-side LocalScript that provides a ground and wall detection helper for a custom character in an underwater research lab environment. The script should be placed in StarterPlayer > StarterPlayerScripts and must work for any number of players simultaneously without causing memory leaks.\n\nThe helper should offer reliable functions to detect whether the character is standing on a surface and whether there is a wall in a given direction, while ignoring the character itself and other players. It should use efficient spatial queries and clean up all resources when a player leaves.", "input": "", "output": "```luau\n--!strict\nconst Players = game:GetService(\"Players\")\nconst Workspace = game:GetService(\"Workspace\")\nconst RunService = game:GetService(\"RunService\")\n\nconst MAX_GROUND_DISTANCE = 25\nconst WALL_CAST_DISTANCE = 8\nconst MAP_FOLDER_NAME = \"UnderwaterLab\"\n\ntype PlayerData = {\n    connection: RBXScriptConnection,\n}\n\nconst playerData: { [Player]: PlayerData } = {}\n\nconst function getRootPart(character: Model): BasePart?\n    if local root = character:FindFirstChild(\"HumanoidRootPart\") :: BasePart? then\n        return root\n    end\n    return nil\nend\n\nconst function createRaycastParams(character: Model): RaycastParams\n    const params = RaycastParams.new()\n    params.ExcludeInstances = { character }\n    if local mapFolder = Workspace:FindFirstChild(MAP_FOLDER_NAME) then\n        params.IncludeInstances = { mapFolder }\n    end\n    return params\nend\n\nconst function isGroundBelow(character: Model): boolean\n    const rootPart = getRootPart(character)\n    if not rootPart then\n        return false\n    end\n    const origin = rootPart.CFrame.Position\n    const direction = Vector3.new(0, -MAX_GROUND_DISTANCE, 0)\n    const params = createRaycastParams(character)\n    const result = Workspace:Raycast(origin, direction, params)\n    return result ~= nil\nend\n\nconst function isWallInDirection(character: Model, direction: Vector3): boolean\n    const rootPart = getRootPart(character)\n    if not rootPart then\n        return false\n    end\n    const origin = rootPart.CFrame.Position + rootPart.CFrame.LookVector * 2\n    const castDirection = direction * WALL_CAST_DISTANCE\n    const params = createRaycastParams(character)\n    const result = Workspace:Raycast(origin, castDirection, params)\n    return result ~= nil\nend\n\nconst function onPlayerAdded(player: Player)\n    const connection = RunService.Heartbeat:Connect(function()\n        const character = player.Character\n        if character then\n            if isGroundBelow(character) then\n                -- ground detected\n            end\n            if isWallInDirection(character, Vector3.new(1, 0, 0)) then\n                -- wall to the right\n            end\n        end\n    end)\n    playerData[player] = { connection = connection }\nend\n\nconst function onPlayerRemoving(player: Player)\n    const data = playerData[player]\n    if data then\n        data.connection:Disconnect()\n        playerData[player] = nil\n    end\nend\n\nPlayers.PlayerAdded:Connect(onPlayerAdded)\nPlayers.PlayerRemoving:Connect(onPlayerRemoving)\n\nfor _, player in Players:GetPlayers() do\n    task.spawn(onPlayerAdded, player)\nend\n```\n\nThis LocalScript provides ground and wall detection functions using RaycastParams with ExcludeInstances and IncludeInstances for efficient spatial queries. It uses const for all non-reassigned bindings and properly disconnects connections per player to prevent memory leaks. The type error was fixed by casting the FindFirstChild result to BasePart?.", "system": "You are an expert Roblox developer. You write modern, strictly typed Luau that uses current (2026) language features and Roblox APIs.", "id": "000052-9c5d", "meta": {"task_kind": "write", "script_kind": "LocalScript (client)", "domain": "ground_check", "theme": "underwater research lab", "complexity": "medium", "features": ["const", "spatial_filters"], "formatted": false, "repairs": 1, "model": "standard", "temperature": 0.3, "provider": "None", "tools": {"stylua": "stylua 2.5.2", "luau-lsp": "1.70.1", "luau-compile": "present"}, "generated_at": "2026-10-07T06:54:41Z"}}
{"instruction": "Create a server Script in ServerScriptService for a cyberpunk alley obstacle course checkpoint system using const that works for keyboard and gamepad players.", "input": "", "output": "```luau\n--!strict\n\nconst Players = game:GetService(\"Players\")\nconst Workspace = game:GetService(\"Workspace\")\nconst ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\n\nconst CHECKPOINT_FOLDER_NAME = \"Checkpoints\"\nconst REMOTE_EVENT_NAME = \"CheckpointActivated\"\nconst DEFAULT_CHECKPOINT_INDEX = 1\nconst RESPAWN_DELAY = 3\n\nconst checkpointEvent = Instance.new(\"RemoteEvent\")\ncheckpointEvent.Name = REMOTE_EVENT_NAME\ncheckpointEvent.Parent = ReplicatedStorage\n\n-- Mutable state\nlocal playerCheckpointIndex: { [Player]: number } = {}\nlocal playerConnections: { [Player]: { RBXScriptConnection } } = {}\n\n-- Load checkpoint parts\nconst checkpointsFolder = Workspace:WaitForChild(CHECKPOINT_FOLDER_NAME)\nlocal checkpoints: { BasePart } = {}\nfor _, child in checkpointsFolder:GetChildren() do\n    if child:IsA(\"BasePart\") then\n        checkpoints[#checkpoints + 1] = child\n    end\nend\n\n-- Sort by name (assumes numeric suffix)\ntable.sort(checkpoints, function(a: BasePart, b: BasePart): boolean\n    return a.Name < b.Name\nend)\n\n-- Find index of a checkpoint part\nconst function getCheckpointIndex(part: BasePart): number?\n    for index, checkpoint in checkpoints do\n        if checkpoint == part then\n            return index\n        end\n    end\n    return nil\nend\n\n-- Set player's checkpoint and notify\nconst function setPlayerCheckpoint(player: Player, index: number)\n    playerCheckpointIndex[player] = index\n    checkpointEvent:FireClient(player, \"CheckpointSet\", index)\nend\n\n-- Respawn player at last checkpoint\nconst function respawnPlayer(player: Player)\n    task.wait(RESPAWN_DELAY)\n    if local character = player.Character then\n        character:Destroy()\n    end\n    player:LoadCharacterAsync()\nend\n\n-- Handle new player\nconst function onPlayerAdded(player: Player)\n    setPlayerCheckpoint(player, DEFAULT_CHECKPOINT_INDEX)\n\n    const characterConnection = player.CharacterAdded:Connect(function(character: Model)\n        if local humanoid = character:FindFirstAncestorOfClass(\"Humanoid\") then\n            humanoid.Died:Connect(function()\n                respawnPlayer(player)\n            end)\n        end\n    end)\n\n    const remoteConnection = checkpointEvent.OnServerEvent:Connect(function(p: Player, part: BasePart)\n        if local index = getCheckpointIndex(part) then\n            setPlayerCheckpoint(p, index)\n        end\n    end)\n\n    playerConnections[player] = { characterConnection, remoteConnection }\nend\n\n-- Cleanup when player leaves\nconst function onPlayerRemoving(player: Player)\n    const connections = playerConnections[player]\n    if connections then\n        for _, connection in connections do\n            connection:Disconnect()\n        end\n        playerConnections[player] = nil\n    end\n    playerCheckpointIndex[player] = nil\nend\n\n-- Connect events\nPlayers.PlayerAdded:Connect(onPlayerAdded)\nPlayers.PlayerRemoving:Connect(onPlayerRemoving)\n\n-- Handle players already present\nfor _, player in Players:GetPlayers() do\n    task.spawn(onPlayerAdded, player)\nend\n\n-- Optional debug export\nreturn {\n    Checkpoints = checkpoints,\n    GetPlayerCheckpoint = function(player: Player): number?\n        return playerCheckpointIndex[player]\n    end,\n}\n```\n\nThe script implements a checkpoint system for a cyberpunk alley obstacle course, using const for all services, constants, and function definitions. It listens for client activation events via a RemoteEvent, stores each player's last checkpoint, and respawns them on death after a delay, working with both keyboard/mouse and gamepad players.", "system": "You are an expert Roblox developer. You write modern, strictly typed Luau that uses current (2026) language features and Roblox APIs.", "id": "000063-6a21", "meta": {"task_kind": "write", "script_kind": "Script (server, in ServerScriptService)", "domain": "checkpoint_system", "theme": "cyberpunk alley", "complexity": "medium", "features": ["const"], "formatted": false, "repairs": 0, "model": "standard", "temperature": 0.3, "provider": "None", "tools": {"stylua": "stylua 2.5.2", "luau-lsp": "1.70.1", "luau-compile": "present"}, "generated_at": "2026-10-07T06:56:46Z"}}