DEV Community

CyberMax
CyberMax

Posted on Originally published at cybermaxtools.com

Roblox tycoon dropper tutorial: conveyors, upgraders and a collector in one server script

A tycoon is a small factory: something drops, a belt carries it, machines raise its value and a collector pays out. Here is the whole loop for Roblox in one server script, driven by tags and attributes so that building a new plot needs no code.

The short version

Build each tycoon as a Model tagged "Tycoon" with a claim pad, droppers, conveyors, upgraders, a collector and buttons, and run it from one server script. Droppers spawn parts that carry a Value attribute; a conveyor is an anchored part with a velocity; upgraders multiply the value once each; the collector turns the value into the owner's cash. Cash lives on the server.

Set it up in Studio

  1. Build a Model in Workspace with these children: a part ClaimPad, a part Collector, and folders Droppers, Conveyors, Upgraders, Buttons and Locked.
  2. Droppers: anchored parts above the belt. Give each the attributes Value (number) and Interval (seconds).
  3. Conveyors: anchored parts whose front face points the way drops should travel. Optional attribute Speed.
  4. Upgraders: anchored parts with CanCollide off, placed across the belt so drops pass through. Attribute Multiplier.
  5. Buttons: parts with the attributes Price and Unlocks (the name of a dropper in Locked). Locked droppers start with Transparency 1.
  6. Select the Model, open Properties > Tags and add the tag Tycoon. Copy the Model for each plot.
  7. In ServerScriptService, add a Script and paste the code. Press Play, step on the claim pad and watch the cash count up.

The code

ServerScriptService/Tycoon (Script)

local CollectionService = game:GetService("CollectionService")
local Debris = game:GetService("Debris")
local Players = game:GetService("Players")

local DROP_LIFETIME = 30 -- seconds before a stuck drop is removed
local MAX_DROPS = 60 -- per tycoon, so a jammed belt cannot lag the server

local owners = {} -- [tycoon] = player
local cash = {} -- [player] = number (load and save this with your player data)
local dropCount = {} -- [tycoon] = drops alive right now

local function setCash(player, amount)
    cash[player] = amount
    local stats = player:FindFirstChild("leaderstats")
    if stats then
        stats.Cash.Value = amount
    end
end

local function onJoin(player)
    local stats = Instance.new("Folder")
    stats.Name = "leaderstats"
    local value = Instance.new("IntValue")
    value.Name = "Cash"
    value.Parent = stats
    stats.Parent = player
    setCash(player, 0)
end

local function spawnDrop(tycoon, dropper)
    if (dropCount[tycoon] or 0) >= MAX_DROPS then
        return
    end
    local drop = Instance.new("Part")
    drop.Name = "Drop"
    drop.Size = Vector3.new(1, 1, 1)
    drop.CFrame = dropper.CFrame * CFrame.new(0, -2, 0)
    drop:SetAttribute("Value", dropper:GetAttribute("Value") or 1)
    drop.Parent = tycoon.Drops
    drop:SetNetworkOwner(nil) -- the server moves drops; a client cannot fling them into the collector
    dropCount[tycoon] = (dropCount[tycoon] or 0) + 1
    drop.Destroying:Connect(function()
        dropCount[tycoon] -= 1
    end)
    Debris:AddItem(drop, DROP_LIFETIME)
end

local function startDropper(tycoon, dropper)
    task.spawn(function()
        while dropper:IsDescendantOf(workspace) do
            task.wait(dropper:GetAttribute("Interval") or 2)
            if owners[tycoon] then
                spawnDrop(tycoon, dropper)
            end
        end
    end)
end

local function setupTycoon(tycoon)
    local drops = Instance.new("Folder")
    drops.Name = "Drops"
    drops.Parent = tycoon

    -- 1. Claim pad: the first player to step on it owns this tycoon. One tycoon per player.
    tycoon.ClaimPad.Touched:Connect(function(hit)
        local player = Players:GetPlayerFromCharacter(hit.Parent)
        if not player or owners[tycoon] then
            return
        end
        for _, owner in owners do
            if owner == player then
                return
            end
        end
        owners[tycoon] = player
        tycoon:SetAttribute("OwnerUserId", player.UserId)
        tycoon.ClaimPad.Transparency = 1
        tycoon.ClaimPad.CanTouch = false
    end)

    -- 2. Conveyors: an anchored part with a velocity carries whatever rests on it, without moving itself.
    for _, belt in tycoon.Conveyors:GetChildren() do
        belt.AssemblyLinearVelocity = belt.CFrame.LookVector * (belt:GetAttribute("Speed") or 8)
    end

    -- 3. Upgraders: multiply a drop's value, once per upgrader.
    for _, upgrader in tycoon.Upgraders:GetChildren() do
        local seen = setmetatable({}, { __mode = "k" })
        upgrader.Touched:Connect(function(hit)
            if hit.Parent ~= drops or seen[hit] then
                return
            end
            seen[hit] = true
            hit:SetAttribute("Value", hit:GetAttribute("Value") * (upgrader:GetAttribute("Multiplier") or 2))
        end)
    end

    -- 4. Collector: a drop that reaches it becomes the owner's cash.
    tycoon.Collector.Touched:Connect(function(hit)
        if hit.Parent ~= drops then
            return -- not a drop of this tycoon (or already collected)
        end
        local value = hit:GetAttribute("Value")
        local owner = owners[tycoon]
        hit:Destroy()
        if owner and value then
            setCash(owner, cash[owner] + value)
        end
    end)

    -- 5. Buttons: the owner walks onto one to buy the dropper it names.
    for _, button in tycoon.Buttons:GetChildren() do
        local bought = false
        button.Touched:Connect(function(hit)
            local player = Players:GetPlayerFromCharacter(hit.Parent)
            if bought or not player or player ~= owners[tycoon] then
                return
            end
            local price = button:GetAttribute("Price") or 0
            if cash[player] < price then
                return
            end
            bought = true
            setCash(player, cash[player] - price)
            local dropper = tycoon.Locked:FindFirstChild(button:GetAttribute("Unlocks") or "")
            if dropper then
                dropper.Transparency = 0
                dropper.Parent = tycoon.Droppers
                startDropper(tycoon, dropper)
            end
            button:Destroy()
        end)
    end

    for _, dropper in tycoon.Droppers:GetChildren() do
        startDropper(tycoon, dropper)
    end
end

Players.PlayerAdded:Connect(onJoin)
for _, player in Players:GetPlayers() do
    onJoin(player)
end

Players.PlayerRemoving:Connect(function(player)
    cash[player] = nil
    for tycoon, owner in owners do
        if owner == player then
            owners[tycoon] = nil
            tycoon:SetAttribute("OwnerUserId", nil)
            tycoon.ClaimPad.Transparency = 0
            tycoon.ClaimPad.CanTouch = true
            for _, drop in tycoon.Drops:GetChildren() do
                drop:Destroy()
            end
        end
    end
end)

for _, tycoon in CollectionService:GetTagged("Tycoon") do
    setupTycoon(tycoon)
end
CollectionService:GetInstanceAddedSignal("Tycoon"):Connect(setupTycoon)
Enter fullscreen mode Exit fullscreen mode

How the conveyor moves parts

A conveyor does not move. It is an anchored part with AssemblyLinearVelocity set: the physics engine treats its surface as moving and carries along anything that rests on it. Setting the velocity from the part's LookVector means you aim a belt by rotating it in Studio, with no numbers to edit.

Why drops are owned by the server

By default Roblox lets the nearest player's device simulate loose parts, which makes movement smooth but also lets an exploiter teleport those parts. SetNetworkOwner(nil) keeps drops under server physics, so the only way into the collector is along the belt.

The collector also checks that the part it touched is inside this tycoon's Drops folder. A part thrown in from elsewhere is ignored.

Keeping the server fast

Every drop is a physics part, and a tycoon server can hold many plots. Two limits keep that under control: MAX_DROPS stops a jammed belt from piling up parts, and Debris removes any drop that has not reached the collector after 30 seconds.

Large tycoon games often go further and do not simulate drops at all: the server adds income on a timer and clients draw the moving parts as decoration. That is more work, and worth it once many players share a server.

Making it a full tycoon

What turns this into a game is the content around it: more buttons, walls and decorations that unlock in order, upgrader tiers and a rebirth that resets the plot for a permanent bonus. Save the player's cash and the names of the buttons they bought, and rebuild the plot from that list when they return.

Good to know

  • Touched fires many times for one contact. The collector is safe because it destroys the drop on the first event, after which the part is no longer in the Drops folder. Each upgrader remembers the drops it has already boosted.
  • Cash is a number in a server table; leaderstats only displays it. If scripts added cash by editing the IntValue, a mistake anywhere could change a player's balance.
  • When the owner leaves, the plot is released: the claim pad returns and leftover drops are removed, so the next player starts clean.

Questions

How do I give each player their own plot automatically?

Keep the claim pad, or assign a free plot in PlayerAdded by picking the first tycoon without an owner and setting owners[tycoon] yourself.

Why do my drops fall through the conveyor?

Check that the conveyor is anchored with CanCollide on, and that the dropper sits high enough for a drop to spawn above the belt, not inside it.

How do I save a tycoon?

Save cash and a list of purchased button names with the player's data. On join, give the player a plot and run the same unlock code for each saved name without charging.

Can I use one script per tycoon instead?

You can, but one script that sets up every tagged Model is easier to fix: a change is made once, not once per plot.

If you would rather not write it

Start free: the free Millwren sampler: two real modules from the kit (Guard, the server-side checks, and Signal) with the .rbxmx to drag into Studio. The full kit is on the same page. Millwren is a tested tycoon kit: plots with claim and release, physics-free droppers and upgraders with exact income maths, capped offline earnings, rebirths that cannot double-fire, and saving with ordered restore. Free sampler first, then the kit: https://cybermaxtools.com/roblox/kits/millwren/?utm_source=devto&utm_medium=article&utm_campaign=rbxtut-roblox-tycoon-dropper-tutorial

Roblox is a trademark of Roblox Corporation. CyberMax is not affiliated with or endorsed by Roblox.


Published automatically by CyberMax. Every number above comes from the linked public data; nothing is estimated.

Top comments (0)