Any DataStore tips and tricks?

Working on a DataStore for my game that will be required to save the Values of existing Strings etc as well as new Values introduced:


As Players progress through the game, new values will be added into suches as the ‘inParty’ and ‘inStorage’. I need to be able to save these - Am I correct in thinking I use:

for _,v in pairs (Player:GetDescendants()) do
if v:IsA("StringValue") or v:IsA("BoolValue") then

If your intention is to iterate through an instance data set that uses ValueObjects, instead of checking each individual class you run them against ValueBase with IsA. If you need extra insurance (you really don’t), you can check if the ClassName has Value in it.

Another tip is that for this kind of thing, you should be using ipairs as GetDescendants generates an array. You don’t need pairs, which is common for cases where the index can be unknown or arbitrary. ipairs is also faster than pairs and canonically correct in this scenario.

for _, v in ipairs(Player:GetDescendants()) do
    if v:IsA("ValueBase") --[[or v.ClassName:match("Value")]] then
        -- code

If you’re looking for DataStore tips and tricks in general, then there’s an infinite amount of them to go around. I personally have a lot of tips and tricks I could offer but probably not a lot of time to explain them.

In this kind of scenario, I typically do not rely on the player as a data dependency. I usually hold data in ServerStorage or ReplicatedStorage with according methods to fetch or set them as needed. I find that storing data in player objects is incorrect or just not the kind of style I prefer. If I need data to be under the player, then it’s definitely not data I intend on saving later.