Saving data for a Collectathon-Style game with a large amount of collectables (1000+)

The game I’m working on is all about collecting coins that are scattered across the map. I want the game to remember what coins have been collected and which ones are still available. For the rest of the game’s datastores, I’m using ProfileService.

I was thinking about looping over every coin and sending some “collected” attribute to a big table, which would then be sent to the sever. But I imagine this wouldn’t be very performate since my game is going to have 1000s of coins.

My second idea was breaking the coins up into “Chunks” and just saving how many coins in each chunk have been collected. This would lose specificity, but I imagine this would be much more performant.

I haven’t tried either of these ideas yet, because I want to make sure my initial idea works before I commit to scripting. I’ve looked at other people who are saving a large quantity of values and see they are using JSON, would learning that help me out?

Any support is appreciated, I don’t need full scripts but just a guide in the right direction.

What you could do is have a module which contains data for each of the coins and have the ID be the key – then as far as saving, you’d only have to save the IDs of those they’ve collected. Something like this:

Coin Info Module

local Public = {}

Public.Coins = {
	[1] = {
		Id = 1,
		CFrame = CFrame.new() -- CFrame of where it's located
		-- any other data you want tied to that coin
	},
}

return Public

Data Format

local Data = {
	['CoinId'] = os.time() -- timestamp of when it was collected maybe?
}

Then you could just iterate through the coin data module however you set up to check let’s say the first 1000, if any of those IDs exist in the data, don’t render it?

Hope this helped! :slight_smile: