§ How to · with Forge AI

How to make a Roblox shop system (with AI)

A Roblox shop system needs three wired-up parts: a server-side currency check, an item delivery pipeline, and (optionally) developer product / gamepass purchase hooks. Forge AI generates all three in 47 seconds.

5 files · 180 lines · 47 seconds · 1 credit. Robux + in-game currency, both server-validated.

Currency-checked purchase

Server reads leaderstats currency, deducts on confirm, delivers item. Client never gets to write currency.

Item delivery pipeline

Generic 'give item' interface — pet, weapon, cosmetic, multiplier. Plug into your inventory system.

Developer product hooks

MarketplaceService:ProcessReceipt handles Robux purchases. Idempotent receipt processing.

Gamepass-gated items

Some items only purchasable if the player owns a specific gamepass. Server-checked.

Stock + cooldown

Optional per-item stock count and cooldown. Limited-time items use timestamped expiry.

Shop UI

Grid of items with cost, icon, owned indicator. Animated buy confirmation.

Files Forge AI ships for this prompt

5 files · 180 lines · 47 seconds · 1 credit

ServerScriptService/ShopService.lua

Currency check + delivery + ProcessReceipt

78 lines

ReplicatedStorage/Modules/ShopConfig.lua

Item table: id, name, cost, type, stock

42 lines

ReplicatedStorage/Remotes/PurchaseRemote

Client → server purchase request

instance

StarterGui/ShopUI.lua

Grid view + buy buttons + confirm modal

48 lines

StarterGui/PurchaseToast.lua

Server-fired purchase confirmation pop-up

12 lines

Sample output: ServerScriptService/ShopService.lua

--!strict
-- ServerScriptService/ShopService.lua  (Forge AI · excerpt)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PurchaseRemote = ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("PurchaseRemote")
local Config = require(ReplicatedStorage.Modules.ShopConfig)

PurchaseRemote.OnServerInvoke = function(player: Player, itemId: string): boolean
    local item = Config[itemId]
    if not item then return false end
    local stats = player:FindFirstChild("leaderstats")
    local cash = stats and stats:FindFirstChild("Cash")
    if not cash or cash.Value < item.cost then return false end
    if item.gamepassRequired then
        local owned = pcall(function()
            return game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, item.gamepassRequired)
        end)
        if not owned then return false end
    end
    cash.Value -= item.cost
    -- delivery: plug into your inventory module
    require(script.Parent.Inventory):AddItem(player, itemId)
    return true
end

Building a Roblox shop system

Shop systems are where bad code costs Robux. The two patterns that determine whether your shop survives launch: server-side currency validation, and idempotent ProcessReceipt for Robux items. Forge AI ships both.

Server-side currency means the client never gets to write a leaderstats value. PurchaseRemote.OnServerInvoke reads cash, validates against item cost, deducts on success — atomic in a single function. The exploit pattern of intercepting the remote and writing 'free' fails because the server never reads the client's claim.

Idempotent ProcessReceipt matters because Roblox sometimes retries receipts on disconnect — if your handler is not idempotent, players can get their item twice (or zero times). Forge ships the standard Roblox idempotency pattern: receipt ID stored in a per-player ProcessedReceipts table, duplicate IDs return the same status code without re-delivering.

Gamepass gating uses MarketplaceService:UserOwnsGamePassAsync server-side, with a 60-second result cache to avoid throttling. Stock + cooldown features are optional but ready: items can declare stock counts (drops to 0 = sold out) or cooldown timestamps (limited-time event items).

The shop UI is a grid view with cost, icon, owned indicator, and animated buy confirmation. The default style matches the rest of Forge AI generated UIs (dark, glass-morphism), and re-skinning is one constants block at the top of ShopUI.lua.

See more on the Luau generator, the game builder, or browse the full blog.

Frequently asked

Does the shop validate currency server-side?+

Yes. PurchaseRemote.OnServerInvoke reads leaderstats.Cash directly, compares to item cost, deducts on success. Client cannot fake currency or skip the deduction.

Can I sell Robux items (developer products)?+

Yes. ShopService implements MarketplaceService:ProcessReceipt with idempotency — Roblox retries receipts on disconnect, the handler skips duplicates safely.

How do gamepass-gated items work?+

Items can declare gamepassRequired: <id>. ShopService runs UserOwnsGamePassAsync server-side before allowing purchase. Cached results to avoid throttling.

Can items have limited stock or cooldowns?+

Yes. ShopConfig supports stock count and cooldown timestamps. Limited-time items use a timestamped expiry — purchased items deduct from stock atomically.

How is the UI styled?+

Default style is a dark glass-morphism grid (matches Forge AI design). Easy to re-skin via ShopUI.lua — fonts, colors, icons are top-of-file constants.

Related Forge AI prompts