§ How to · with Forge AI
How to make a Roblox pet system (with AI)
A Roblox pet system needs five wired-up parts: pet inventory, rarity tiers, equip/unequip, trading flow, and a save flow. Forge AI generates all five in 1m 28s — plus a daily-reward hook and a shop UI.
11 files · 340 lines · 1m 28s · 1 credit. Pets persist across server restarts, trade-safe by default.
Rarity tiers
Common / Uncommon / Rare / Epic / Legendary / Mythic. Drop weights configurable. Rarity affects sell price and visual aura.
Pet inventory
Per-player table of owned pets. ProfileService-style save flow so progress survives.
Equip / unequip
Up to 3 active pets per player by default. Equipped pets follow the player via BodyPosition + offset.
Trading flow
Two-player request → confirm → confirm → exchange. Server validates ownership of every pet on every step. No middle-click exploits.
Shop UI
Buy random egg per rarity. Currency check server-side, weighted random drop, animated egg-hatch reveal on the client.
Daily rewards
DataStore-backed streak counter. Login bonus by day (1 → 7), streak resets if 36 hours elapse without claim.
Files Forge AI ships for this prompt
11 files · 340 lines · 1m 28s · 1 credit
ServerScriptService/PetService.lua
Pet add/remove/equip/unequip + rarity rolls
78 lines
ServerScriptService/TradeService.lua
Trade request + confirm + exchange (server-validated)
84 lines
ServerScriptService/EggShop.lua
Currency check + weighted random + delivery
42 lines
ServerScriptService/DailyRewards.lua
Streak tracker + reward claim
38 lines
ServerScriptService/SaveService.lua
DataStore wrapper with retry
32 lines
ReplicatedStorage/PetTemplates
Folder of equippable pet Models
instance
ReplicatedStorage/Remotes/TradeRemote
Trade request RemoteEvent
instance
ReplicatedStorage/Remotes/EggBuyRemote
Egg purchase RemoteFunction
instance
StarterGui/PetInventoryUI.lua
Grid view, equip toggle
28 lines
StarterGui/EggShopUI.lua
Buy buttons + hatch animation
24 lines
StarterGui/TradeUI.lua
Trade window with confirm states
14 lines
Sample output: ServerScriptService/TradeService.lua
--!strict
-- ServerScriptService/TradeService.lua (Forge AI · excerpt)
local Players = game:GetService("Players")
local PetService = require(script.Parent.PetService)
local pendingTrades: { [string]: { a: Player, b: Player, aPet: string?, bPet: string?, aConfirm: boolean, bConfirm: boolean } } = {}
local function tradeKey(a: Player, b: Player): string
return math.min(a.UserId, b.UserId) .. "_" .. math.max(a.UserId, b.UserId)
end
local function commitTrade(trade)
if not trade.aPet or not trade.bPet then return end
if not PetService:OwnsPet(trade.a, trade.aPet) then return end
if not PetService:OwnsPet(trade.b, trade.bPet) then return end
PetService:RemovePet(trade.a, trade.aPet)
PetService:RemovePet(trade.b, trade.bPet)
PetService:AddPet(trade.a, trade.bPet)
PetService:AddPet(trade.b, trade.aPet)
endBuilding a Roblox pet system
Pet systems are one of the highest-converting mechanics on Roblox — and the most exploit-bait. The trading flow is where most pet systems lose money: a client-trusted ownership check lets exploiters duplicate legendaries. Forge AI ships server-validated trading by default.
The Forge trade flow is two-player request → confirm → confirm → exchange. At every step the server holds the source of truth for who owns what. Right before the swap, the server re-checks ownership one last time — if either player has sold or duplicated the pet between confirm and exchange, the trade aborts cleanly. Standard middle-click trade exploits do not work against this pattern.
The rarity system uses weighted random with a configurable rarity table. The default is Common 50%, Uncommon 25%, Rare 15%, Epic 7%, Legendary 2.5%, Mythic 0.5% — tune in EggShop.lua. Visual aura matches rarity (color + particle emitter), so a Mythic pet reads instantly.
The save flow is the same SetAsync-with-retry pattern Forge uses for tycoons — pet inventory persists across server restarts, BindToClose handles graceful shutdown, periodic autosave covers crash cases. Daily rewards layer on top: a streak counter increments per day, resets if 36 hours elapse without a claim, awards by day (day 1 small, day 7 jackpot).
See more on the Luau generator, the game builder, or browse the full blog.
Frequently asked
How does trading prevent exploits?+
Every step is server-validated: trade request, pet selection, confirm. Right before the exchange, both players' ownership is re-checked. If either has duplicated or sold the pet, the trade aborts. No client-trusted ownership.
Can I add more rarity tiers?+
Yes. Rarity weights are a Lua table at the top of EggShop.lua. Add a tier, set weight, set sell price multiplier — Forge handles the rest.
Do pets follow the player visually?+
Yes. Equipped pets use BodyPosition + offset to hover behind the player. Up to 3 equipped by default — configurable.
How are pets stored?+
Per-player Lua table saved via DataStore on PlayerRemoving and every 60 seconds. Retry-with-backoff handles throttling.
Can I add gacha boxes?+
Yes. EggShop.lua exposes the weighted random function — point it at a different rarity table for premium gacha. Forge can extend with a Robux purchase hook.
Related Forge AI prompts
Roblox shop system
5 files · 180 lines · 47 seconds · 1 credit. Robux + in-game currency, both server-validated.
Roblox daily rewards
5 files · 170 lines · 49 seconds · 1 credit. 7-day cycle by default, configurable.
How to use Roblox DataStore the right way
3 files · 140 lines · 36 seconds · 1 credit. Drop-in save service for any game.