Datastore Profile Service Formatting

I was wondering with Datastore having limitations what would be the best way setup my data.

Im using profile service and when making the data template I currently am doing something along the lines of the code below. With this method I have to create a separate variable to handle the indexing, so the more arrays I have within my template data, the more index’s I will have to create

local TEMPLATE = {
    Currency = 0,
	Ban = {nil, nil, nil, nil},
}
local BAN_INDEX = {
	State = 1,
	Reason = 2,
	Date = 3,
	Duration = 4
}
print(playerData.Ban[BAN_INDEX.State])

I was wondering if it would be better to set up the code in this fashion, just because it is cleaner and easier to the eye, my only worry is that data limitations may be hit

local TEMPLATE = {
	Currency = 0,
	Ban = {
		State = nil,
		Reason = nil,
		Data = nil,
		Duration = nil
	}
}
print(playerData.Ban.State)

Thanks for the help

The latter, DataStores only accept single values, you can’t assign a tuple (multiple values) to any given DataStore key, as such wrapping everything inside a single dictionary is the way to go, as opposed to wrapping everything inside multiple dictionaries and necessitating the existence of multiple DataStores for which these dictionaries will be saved and loaded to and from respectively.

1 Like

As someone who has started using ProfileService for most of my projects in the past few months you’ll have to put everything (from my understanding) under one table.

I’ve used ProfileService for my roleplay game so I wasn’t really worried about hitting any Data caps while saving my games data for each player so I was able to do a lot more with that data such as a more advanced vehicle customization system

Unless you’re working on a building game I don’t think you’ll hit a datacap for awhile.

edit: after giving a full re-read over your post yeah you’ll be doing what you did for the second lua quote.

local TEMPLATE = {
    Currency = 0,

    BAN_INDEX = {
	    State = 1,
	    Reason = 2,
	    Date = 3,
	    Duration = 4
    }
}