Rebirth calculations don't work

Hello everyone!

I need help with the rebirth system I use in my simulator game. Here is the code:

function updateRebirthTable(player, rebirthAmount)
	local rebirthTable = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000, 100000000000, 1000000000000}
	local rebirthsCalc = player.leaderstats.Rebirths.Value / 100
	
	rebirthsCalc = roundDown(rebirthsCalc, 0)
	
	local tapsNeededTable = {}
	local m2 = 0.03
	local scn = 10
	for count = 1, 9 do
		tapsNeededTable[count] = roundUp(scn, 0)
		scn = scn - (scn * m2)
		scn = scn * 10
	end
	
	local currentClicks = player.leaderstats.Clicks.Value
	for index, value in ipairs(rebirthTable) do
		local newRebirthButton = rebirthButton:Clone()
		local newRebirthLabel = rebirthLabel:Clone()
		local requiredClicks = tapsNeededTable[index]
		local amount = value
		
		local requiredClicksPlusAmount = requiredClicks + (amount + rebirthAmount)
		requiredClicksPlusAmount = roundUp(requiredClicksPlusAmount, 0)
		newRebirthButton.Text = formatNumber.FormatCompact(amount).." Rebirths ("..formatNumber.FormatCompact(requiredClicksPlusAmount).." Clicks)"
		newRebirthLabel.Text = formatNumber.FormatCompact(amount).." Rebirths ("..formatNumber.FormatCompact(requiredClicksPlusAmount).." Clicks)"
		
		if currentClicks >= requiredClicksPlusAmount then
			newRebirthButton.BackgroundColor3 = Color3.fromRGB(32, 255, 28)
			newRebirthButton.Active = false
			newRebirthButton.MainValue.Value = value
			newRebirthButton.Parent = player.PlayerGui.Frames.RebirthFrame.RebirthFrame2.ScrollingFrame
		else
			newRebirthLabel.BackgroundColor3 = Color3.fromRGB(255, 75, 75)
			newRebirthLabel.Parent = player.PlayerGui.Frames.RebirthFrame.RebirthFrame2.ScrollingFrame
		end
	end
end

This is the function I use to calculate the price of my rebirth system and display it in a button. The “m2” variable is the multiplier. The bigger that number, the bigger the amount needed for rebirth is more. “0.03” is a great amount for beginner players, but once your rebirths get into the thousands and millions, the multiplier doesn’t work anymore because the numbers are so big.

Can you guys please help? I want to know how I can “scale” this m2 variable.

Please ask questions if you have any

Thanks

-GreenTreeGamingYT

That’s Probably because it reaches the Number Limit.

What exactly do you mean by “scale?”

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.