§ How to · with Picoo

How to make a Roblox mining game (with AI)

By Sametcan Tasgiran, Founder & Developer·Published ·Updated

A Roblox mining game needs five pieces: ore nodes, pickaxe damage, ore rarity tiers, respawn timers, and a smelting and selling flow. Describe the game in a prompt and Picoo writes the scripts. The example below covers the nodes, pickaxes, rarity, respawns and smelting, and selling can be added in a follow-up prompt.

Example build: 7 files · 222 lines. The server tracks node HP, checks reach and pickaxe tier on every swing, and respawns nodes on a per-ore timer.

Ore nodes

Parts tagged OreNode, each with an OreType attribute. OreConfig gives every ore type its HP and yield. A pickaxe swing fires the SwingPickaxe remote, the server subtracts damage, and a node at 0 HP gives its yield to the player who broke it.

Pickaxe damage scaling

PickaxeConfig gives each pickaxe a damage stat, and each ore has a minPickaxe value. A swing from a pickaxe below an ore's minPickaxe does nothing, so better pickaxes open up harder ores.

Ore rarity tiers

OreConfig lists each ore with a rarity, HP, price and respawn time, from common ores like coal up to rare ones like diamond. You place and tag the nodes, so you decide where each ore appears.

Respawn timers

A broken node turns invisible and non-collidable and can't be mined until its ore's respawnSeconds pass, then it comes back. Give rarer ores longer timers.

Smelting flow

SmeltingManager runs a queue per furnace and turns raw ore into ingots one piece at a time on a smelt timer. You choose the smelt time and what an ingot is worth.

Pickaxe upgrades

PickaxeConfig stores each pickaxe's cost next to its damage. A shop to buy pickaxes, or crafting them from ingots, can be added in a follow-up prompt.

Example output from a build like this

7 files in this example. Picoo writes this code for your prompt, so file names and sizes vary.

ServerScriptService/MiningManager.lua

Node damage, drop, respawn timing

ServerScriptService/SmeltingManager.lua

Furnace queue, smelt timers, ingot output

ServerScriptService/PickaxeService.lua

Equipped pickaxe damage lookup

ReplicatedStorage/Modules/OreConfig.lua

Per-ore HP, rarity, price, respawn time

ReplicatedStorage/Modules/PickaxeConfig.lua

Per-pickaxe damage, cost

ReplicatedStorage/Remotes/SwingPickaxe

Client hit → server damage

StarterGui/MiningHUD.lua

Current pickaxe, ore counts, smelting queue

Sample output: ServerScriptService/MiningManager.lua

--!strict
-- ServerScriptService/MiningManager.lua  (example output · excerpt)
local CollectionService = game:GetService("CollectionService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local OreConfig = require(ReplicatedStorage.Modules.OreConfig)
local PickaxeService = require(script.Parent.PickaxeService)
local SwingPickaxe = ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("SwingPickaxe")

local MAX_REACH = 12 -- studs between the player and the node

local nodeHP: { [BasePart]: number } = {}
local broken: { [BasePart]: boolean } = {}

SwingPickaxe.OnServerEvent:Connect(function(player: Player, node: any)
    if typeof(node) ~= "Instance" or not node:IsA("BasePart") then return end
    if not CollectionService:HasTag(node, "OreNode") or broken[node] then return end
    local character = player.Character
    local root = character and character:FindFirstChild("HumanoidRootPart") :: BasePart?
    if not root or (root.Position - node.Position).Magnitude > MAX_REACH then return end

    local oreType = node:GetAttribute("OreType") :: string
    local config = OreConfig[oreType]
    if not config then return end

    local pickaxeDamage = PickaxeService:getDamage(player)
    if pickaxeDamage < config.minPickaxe then return end  -- pickaxe too weak

    nodeHP[node] = (nodeHP[node] or config.hp) - pickaxeDamage

    if nodeHP[node] <= 0 then
        nodeHP[node] = nil
        broken[node] = true  -- no mining until it respawns
        node.Transparency = 1
        node.CanCollide = false
        -- InventoryServer is the server API of Picoo's inventory recipe
        local inventory = _G.InventoryServer
        if inventory then inventory.add(player, oreType, config.yield) end

        task.delay(config.respawnSeconds, function()
            broken[node] = nil
            if not node.Parent then return end
            node.Transparency = 0
            node.CanCollide = true
        end)
    end
end)

Building a Roblox mining game

Mining games are an evergreen Roblox genre. The pattern works because the loop — find ore, mine it, sell it, buy a better pickaxe — is satisfying at every scale. New players mine coal; veterans mine the rarest ore; both feel productive. Describe that loop in a prompt and Picoo writes the scripts for it.

The example build on this page has 7 files. OreConfig.lua holds each ore's HP, yield, rarity, price and respawn time. PickaxeConfig.lua holds the pickaxe tiers. MiningManager runs node damage and drops. The configs sit apart from the logic, so adding an ore is one config entry plus the tagged node Parts.

Node HP and pickaxe damage together create the progression. Each ore sets a minPickaxe threshold, so a starter pickaxe mines the common ore and does nothing to the next tier. Price the harder ores higher and each pickaxe upgrade pays for the one after it.

Rarity drives long-term play. Put common nodes everywhere and rare ones in a few zones, and players move to the higher-value zones as their pickaxe improves. Respawn timers back this up: a longer respawnSeconds on rare ores makes a fresh rare node feel like a find.

Smelting adds a second step. SmeltingManager runs a furnace queue that turns raw ore into ingots one piece at a time. If an ingot is worth more than the raw ore, players who keep the furnace busy earn more than players who sell raw ore, and the queue runs without constant attention.

The pickaxe upgrade path is the long-term goal. PickaxeConfig stores each tier's damage and cost. Ask in a follow-up prompt for a crafting step that spends ingots on the next pickaxe, which gives smelted ingots a use beyond selling. A prompt that asks for a "mining tycoon" goes to Picoo's tycoon recipe instead, which builds a dropper tycoon with a factory, candy or space-mining theme.

See more on the Luau generator, the AI Luau script writer, the 3D model generator and the game builder, read how Picoo compares with ChatGPT, or browse the full blog.

Frequently asked

How do I add a new ore type?+

In this example, add an entry to OreConfig.lua with hp, yield, rarity, price, minPickaxe (the lowest pickaxe damage that can mine it) and respawnSeconds. Tag the node Parts with 'OreNode' and set their OreType attribute to the entry's key. If the ore goes into Picoo's inventory recipe, add the same id to Items.Defs in ReplicatedStorage.Items too, because InventoryServer.add only accepts ids listed there.

Can different pickaxes mine different ores?+

Yes. Each ore has a minPickaxe value, and MiningManager ignores swings from a pickaxe whose damage is below it. Set the damage numbers in PickaxeConfig and the thresholds in OreConfig. Buying or crafting the next pickaxe can be added in a follow-up prompt.

How does smelting work?+

SmeltingManager keeps a queue per furnace and turns raw ore into ingots one piece at a time on a smelt timer. MiningHUD shows the active queue. You pick the smelt time and how much an ingot is worth compared with raw ore.

What about a mining cart system?+

Ask for it in a follow-up prompt, for example a cart Tool that carries extra ore so players can mine longer before heading back to sell.

How do players see what they've mined?+

In this example, MiningHUD shows the equipped pickaxe and its damage, how much of each ore the player has, and the smelting queue with its timers.

Related Picoo prompts