FFORGEBLOX

Tutorial · 13 min read · Updated October 2026

How to make a Roblox RPG with AI, step by step

RPGs and combat games are where AI-written Roblox code most often goes wrong, because combat is a network problem: the client wants instant feedback, but if the client decides who got hit, exploiters hit everyone from across the map. The eight messages below build a small RPG with melee combat, enemies, XP, loot, quests and a boss inside your own Roblox Studio place, with the server deciding every hit. They are written for ForgeBlox (formerly Forge).

Before you start

Message 1: melee combat

Build melee combat. A Sword tool in StarterPack. On click the client plays
a swing animation immediately and fires a Swing remote with no arguments.
The server enforces a 0.45 second cooldown per player, tracks a 3-hit
combo (resets after 1.2 seconds), and on the hit frame queries a box in
front of the character with workspace:GetPartBoundsInBox and an
OverlapParams that excludes the attacker. Each Humanoid is damaged once
per swing: 10, 10, then 18 on the third hit. Show floating damage numbers
to the attacker. Add a training dummy with 200 health. Playtest, hit the
dummy 6 times, screenshot, stop.

What to check: the Swing remote carries nothing. If the AI makes the client send "I hit this target", ask it to move hit detection to the server.

Message 2: enemies

Add enemy NPCs: a Goblin model with a Humanoid, 60 health, 8 damage per
hit, 1.2 second attack cooldown. A server AI script per enemy with idle,
chase and attack states: idle wanders near its spawn, chase starts when
a player is within 40 studs and uses PathfindingService with a path
recomputed every 0.5 seconds, attack when within 5 studs, and it returns
home if the player gets 80 studs from spawn. A spawner keeps 6 goblins
in Zone 1, respawning 10 seconds after a death. Give the server network
ownership of enemy parts. Playtest, fight two goblins, screenshot.

Message 3: XP and levels

Track damage dealt per player on each enemy. On death, split the enemy's
XP (Goblin 20) by damage share. Level curve: XP to next level =
floor(50 * level ^ 1.5). On level up: +5 max health, +1 stat point, a
level-up effect. Add a Stats UI to spend points on Strength (+2% damage)
and Vitality (+10 health), validated on the server. Show level and an
XP bar on the HUD. Playtest to level 3 using execute_luau to grant XP,
screenshot.

Message 4: loot and equipment

Add ReplicatedStorage/Config/Items (id, name, type, damage or defense,
rarity) and per-enemy loot tables { itemId, chance }. On death the server
rolls loot for each player who did at least 20% of the damage and drops
it as a pickup only that player can collect. Inventory UI with equip
slots for Weapon and Armor; equipping changes damage and defense on the
server. Every item instance has a unique id. Playtest a few kills,
equip a drop, screenshot.

Message 5: quests

Add a quest giver NPC with a ProximityPrompt and a dialog UI. Quests are
data in Config/Quests: "Kill 5 Goblins" (reward 100 XP, 50 Gold) and
"Collect 3 Goblin Ears" (dropped 40% of the time). The server tracks
progress per player, updates a quest tracker on the HUD, and grants
rewards once on turn-in. Add Gold as a leaderstat. Complete both quests
in a playtest, screenshot.

Message 6: a boss

Add a Goblin King boss in an arena behind a door that opens at level 5.
800 health, two phases: above 50% it does a slam with a red circle
telegraph on the ground for 1 second before the damage; below 50% it
also summons 2 goblins every 15 seconds. Damage only applies to players
inside the circle when it lands. On death, a chest appears that gives
every player who did damage a guaranteed rare item. Respawn after 3
minutes. Playtest the fight, screenshot both phases.

Telegraphs are what make a boss feel fair. If players die without seeing why, they quit.

Message 7: saving and passes

Save level, XP, stat points, Gold, inventory (items by unique id),
equipped items and quest progress with DataStoreService: session-locked
with UpdateAsync, autosave every 60 seconds, save on leave and
BindToClose. Add a VIP game pass (placeholder id): +20% XP and a name
tag, checked on join with UserOwnsGamePassAsync in a pcall and applied
immediately after purchase. Test: level up, equip, stop, start, confirm.

Selling Gold or potions for Robux? Use one ProcessReceipt with idempotent grants; the game pass guide has the prompt.

Message 8: the security pass

Review every remote on the server: Swing has a cooldown and no arguments,
stat spending validates points, equip checks the item id belongs to the
player, pickups check range and owner, quest turn-in checks progress.
Clamp health, damage and Gold. Confirm no client-sent target, damage or
amount is trusted. Fix what you find and summarise.

Numbers that feel fair

ThingStarting valueWhy
Swing cooldown0.45 s, 3-hit combo with a heavier third hitFast enough to feel responsive, slow enough to read
First enemyDies in 5 to 6 hitsA fight, not a chore
Level curve50 × level1.5 XPEarly levels quick, later ones a goal
Boss telegraph1 second warningDodgeable on mobile

What it costs

On Sonnet 5.5 this sequence runs about 4,000 to 9,000 credits ($40–90), more with many enemy types or a lot of UI polish. Packs are $10 = 1,000 credits, $25 = 2,750, $60 = 7,200 and $150 = 19,500, and credits never expire; Builder ($19/month, 2,000 credits) and Pro ($49/month, 5,600 credits, longer builds) are optional. The price of every message shows before you send it.

Common mistakes the playtests catch

Related guides

Run this sequence in ForgeBlox. Download the Bridge, pair once, paste Message 1. Trial credits, no card. Download the ForgeBlox Bridge →