How do I calculate this?

So I have a tower defense game where you earn 200 coins if you win a certain match. BUT, there are 30 waves. How would I calculate it so it gets split if you lost in the middle of it? For example 2 coins per wave if you gained 100 coins throughout 50 waves.

Maybe you could try something along the lines of this at the end of each match:

local totalReward = 200
local totalWaves = 30
local wavesSurvived = 20
local earnedReward = (totalReward / totalWaves) * wavesSurvived 
2 Likes

is it possible to round it down?

nvm, leaderstats automatically round numbers.

1 Like

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