I am making a game kinda like deathrun, and I need a script that can use the wins and loses and make them a W/L Ratio?? Can anyone help? And I need the whole thing to save to. How could I use DataPersitance for it??
I can help you with the basic math for this problem. So, you have wins, and losses. Let's say that the player has won 5 times, and lost 20 times. We can find the ratio by dividing 5 by 20. This gives us 0.25, which is the ratio. So the code would look something like this:
WinLossRatio = wins / losses
Now, we are still presented with an issue, for example, let's say a player has lost 7 times and won 2 times. If we do the math for this issue, it comes up with 0.28571428571, that is a bit long. In this case, we will need to round the number.
function round(WinLossRatio, 2) --First argument is the number, so we'd put WinLossRatio. The second argument is decimal, so we'd put it what decimal place we want the number rounded to. decimal=decimal or 0 local mult=10^decimal return math.floor(number*mult+.5)/mult end