1 | script.Parent.Touched:Connect( function (Object) |
2 | local Player = game.Players [ Object.Parent.Name ] |
3 | if Player.leaderstats.Coins.Value > = 100 then |
4 | Player.leaderstats.Rebirths.Value = Player.leaderstats.Rebirths.Value + (Player.leaderstats.Coins.Value/ 100 ) |
5 | Player.leaderstats.Coins.Value = Player.leaderstats.Coins.Value - (Player.leaderstats.Coins.Value/ 100 ) * 100 |
6 |
7 | end |
8 |
9 | end ) |
My coin value ends up being 0
You can use the / operator to check how many times 100 goes into the amount of coins the user has.
1 | script.Parent.Touched:Connect( function (Object) |
2 | local Player = game.Players [ Object.Parent.Name ] |
3 | if Player.leaderstats.Coins.Value > = 100 then |
4 | local RebirthsToAward = math.floor(coins/ 100 ) -- Preventing decimals |
5 | Player.leaderstats.Rebirths.Value + = RebirthsToAward |
6 | Player.leaderstats.Coins.Value - = RebirthsToAward * 100 -- Subtracting the amount of coins necessary |
7 |
8 | end |
9 | end ) |