I’m not much of a scripter, but I been trying to figure out how I can make a simple tycoon game (like the ones listed below). I would even be fine with just making the player gain money no matter what but you can upgrade. Any help is greatly appreciated.
1 Like
The simplest way to make an idle money game is to just have a loop give someone X amount of money every X seconds. You can then have an upgrade system which just increases the amount of money given or shorten the duration of time between each loop.
This is a VERY BASIC example of what the engine would look like:
local timeUpgrade = 1 -- Every time this is is purchased, loopTime decreases
local moneyUpgrade = 1 -- Every time this is purchased, moneyGiven increases
local loopTime = 5 / timeUpgrade -- Seconds between each money give starting with 5 seconds
local moneyGiven = 1 * moneyUpgrade -- Amount of money given to a player every loop starting with 1 money
-- Add a leaderstats folder for the player for Money
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local money = Instance.new("IntValue")
money.Name = "Money"
money.Value = 0
money.Parent = leaderstats
end)
-- Give all players money based on upgrades
while task.wait(loopTime) do -- Loop for every (loopTime) number of seconds
for i, player in pairs(game.Players:GetChildren()) do -- For all players:
if player:FindFirstChild("leaderstats") then -- If they have the leaderstats folder:
player.leaderstats.Money.Value += moneyGiven -- Given them (moneyGiven) amount of money
end
end
end
If you want to add upgrades for time and money, you would add more code in here that adds 1 or anything you want to the timeUpgrade
and moneyUpgrade
variables at the top (assuming that the player has enough money).
This is a VERY BASIC script that would only work for a 1 player server, so it won’t be usable if you just paste it into studio. I hope this helps you with your question.
2 Likes