Multiplier system for each rebirth in a game

Hi guys, I’m new here and I finally can post! Don’t be harsh please if I do not understand everything because I am new to lua scripting and trying to learn.

So, I’m making a tycoon. But not the basic tycoon with droppers. The so called “dropper” is actually a script that is giving “Cash” (the in game currency) every 2 seconds. That money is put in a NumberValue called CurrencyToCollect and ,after touching a button, that currency goes into plr.leaderstats.Cash.

I’m trying to make a cash multiplier system for every rebirth that they get. Like, for 1 rebirth you get x1.2 mutliplier, for 2 rebirths you get x1.4 and so on.
The first idea that got into my head was to make a script that, if you have 1 rebirth, you get x1.2 multiplier in every script that is giving you money, but I tough that there are easier ways to make that.
Then I tough about putting all the money in another NumberValue, and multiply that NumberValue with x1.2 every 2 seconds and that value will be transferred to CurrencyToCollect every 2 seconds so it won’t get multiplied twice.

I’m thinking about going the second way since it will be easier to make, but I want to ask better developers about it and here I am, asking for advice from you guys. Thank you.

2 Likes

I would change it for something else. Give each new player a rebirth with multipler of x1.0. For future rebirths increase player’s rebirth multipler value by 0.2. Questions?

It’s kinda the same I tought about it. The problem I’m having is how to make that multiplier.

According to rules of Scripting Support posts rules you should at least try and prove doing that by showing your work (script/scripts). Anything is better than nothing.

I’m not asking for all the code. Just for an idea on how to make a multiplier for what system of cash distribution I have. I could post the rebirth code here, but it might not help. Also it has 500 lines of code :smiley:

Store rebirth value in data store. Make the script responsible for detecting touch for collecting CurrencyToCollect:

  1. When it’s time to give currency to a player, use (in)directly accessed rebirth multipler value and do this simple math: CurrencyToCollect * multipler to calculate cash to give
  2. Reset CurrencyToCollect
  3. Repeat

use (in)directly accessed

indirectly - an another script gets players data from data store and sends rebirth value by using BindableFunction to this script
directly - the script doesn’t ask any other script for any information from data store. The data store thing is done in this script.

1 Like

It could be something like this:

local Rebirths = {
	--1 its the rebirth, 500 its the cash that you need to do a rebirth, 1.5 its the multiplier .
	[1] = {500,1.5};
	[2] = {1000,2.5}
}

local AddCash = function(Player)
	local Rebirth = --Wherever you have it.
	local CurrencyToCollect = --Wherever you have it again.
	local Cash = Player.leaderstats.Cash
	if Rebirth.Value >= 1 then -- Check if player has a rebirth.
		Cash.Value += (CurrencyToCollect.Value * Rebirths[Rebirth.Value][2]) --Returns the value of multiplier for every rebirth.
	else
		Cash.Value += CurrencyToCollect.Value -- if not
	end
end

By the way its just an example, okay?
But I recommend using module scripts in these cases.

5 Likes

Alright so, I’ve made something. But it’s not multiplying enough. Any idea why not? I get 144 instead of 192 per 2 seconds. Also, do you think this is good?

local Owner = script.Parent.Owner
local CurrentPlr = nil
local CurrentPlrId = 0
local TycoonTeamColor = script.Parent.TeamColor
local cooldown = 1

Owner.Changed:Connect(function()
	if Owner.Value ~= nil then
		repeat
			wait(cooldown)
			for i, v in pairs(game:GetService("Players"):GetChildren()) do
				if v.TeamColor == TycoonTeamColor.Value then
							local rebirths = v.leaderstats.Rebirths.Value
							local currencybefore = script.Parent.CurrencyBefore
					local currencycollect = script.Parent.CurrencyToCollect
					while true do
						wait(2)
						if currencybefore.Value ~= 0 then
							if rebirths == 0 then
								wait(0.1)
								currencybefore.Value = currencybefore.Value *1
								currencycollect.Value += currencybefore.Value
								currencybefore.Value = 0
							elseif rebirths == 1 then
								wait(0.1)
								currencybefore.Value = currencybefore.Value *1.2
								currencycollect.Value += currencybefore.Value
								currencybefore.Value = 0
							elseif rebirths == 2 then
								currencybefore.Value = currencybefore.Value *1.4
								currencycollect.Value += currencybefore.Value
								currencybefore.Value = 0
								wait(0.1)
								end
								end
						end
					end
				end
		until Owner.Value == nil
	end
end)

Nevermind, I made it work. I did not change everything but now it’s good. Thank you!