Hiding previously collected coins on rejoin

Hey guys! I’ve already attempted looking up how to do this, however I can’t find anything. Maybe I just don’t know exactly what to look up, but I can’t find anything.

Title pretty much says it all! I’d like to figure out a way to hide previously collected coins on rejoin, so that the players can’t collect infinite coins by just rejoining and having the coins reappear! I’ve guessed using tables will work, I just can’t figure out an easy way to do it. I assume it will have something to do with saving tables in datastores that hold information pertaining to the coin position or something.

Thanks for the help!

Keep track of the coins you collected. To do this, you should be able to identify the coins that the player has collected, and where they usually spawn.

In this case, if you have specific locations that spawn coins, then when the player collects a coin, save a reference or identifier for the spawn itself, and tell the spawn not to spawn any coins. You can do this with a table or dictionary. (They’re pretty much the same with slight differences to the way its indexed.)

And you are right, it will have something to do with datastores. If you have IDs for your spawners that are integers you can save this data in an OrderedDataStore or you can use a regular DataStore if you use a dictionary instead.

https://developer.roblox.com/api-reference/class/DataStoreService

I’ve actually done things like this recently. What I do is load all the coins in instead of removing already collected ones; I do this with an indexed table in a DataStore (like @T0ny suggested). The way I lay this out is indexing every “coin” with a unique ID inside the object itself and checking for that ID in the table when the place loads. (For example, CoinData[1] would correspond with the coin that has the ID 1. That said, my system is engineered with multiplace and lots and lots of values being stored in mind, since data limits per async do exist. If you aren’t going to have a ton of coins, T0ny’s solution may be easier to handle.