Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I make it that you can convert 10 chips to 1 money?

Asked by 8 years ago
script.Parent.DialogChoiceSelected:connect(function(player, choice)
    if (choice==script.Parent.TurnIn) then
        player.leaderstats.Money.Value=player.leaderstats.Money.Value+player.Chips.Value
        player.Chips.Value=0
    end
end)

If a player gets 10 chips, it can convert to 1 money. How can I make this work?

1 answer

Log in to vote
0
Answered by
saenae 318 Moderation Voter
8 years ago

if(choice==script.Parent.TurnIn) then for i = 0, 9 do if (player.Chips.Value-i) == 0 then player.leaderstats.Money.Value = player.leaderstats.Money.Value + (player.Chips.Value-i)/10 player.Chips.Value = player.Chips.Value-(player.Chips.Value-i) break end end end

0
To elaborate on this (since I couldn't really include comments), it starts off by making a loop that subtracts 0-9 from whatever value your chips were at. It then checks to see if that value is divisible by 10, and if it is, it converts that portion to money, and keeps the rest as chips. For example, if you'd had 35 chips, you'd be left with 3 Money, and 5 chips. saenae 318 — 8y
0
Please put any scripts you post in a code block! DevJackB 55 — 8y
0
Sorry about that! I hadn't even known about code blocks 'til yesterday. I'm pretty dull, haha. saenae 318 — 8y
Ad

Answer this question