How can I give a player a gem for every 10 coins they collect

So I would like to make for every 10 coins a player gets they get 1 gem

Do you have any code to show? Because we can’t give you a whole coin to gem ratio system from scratch. We can only help you solve your problem’s on existing code or give you a direction for you to make a solution out of. I would try to keep track of how many coins a player gets by putting it in a dictionary where the player is the key and value is their coins collected, every time a coin gets collected you increase the number by 1 and if the number is 10 or above give the player a gem and reset that coin count to 0.

you should create a new value which you add 1 to with every coin you collect,
then check if its 10, then add a gem and reset that value to 0

Well I have a script that when you kill an npc if gives you money from 30 to 80 and I want every 10 coins they get they get a gem for example if I get 30 coins I get 3 gems

@TenBlocke is on point. We need to see your code before making any further recommendations. You have a script? That should be edited into your post.

Your request is pretty simple but we still need to see your implementation.

Ok I think I found a way

local amount = math.random(30, 80)
local new = amount/10
1 Like

I think you’re missing something.
math.random returns a random integer between its args. If amount was 31 for example, new would be 3.1. 3.1 gems wouldn’t exactly make sense, right?

Consider using math.floor, math.round, or math.ceil on new depending on what you want.