How do i work with outdated datastores?

I’m currently working on a datastore system for my game, which works but when i want to edit what should be in a player’s datastore it creates outdated data which i don’t know how to handle.

For example if i saved a table containing some values like such,

local data = {
max_speed = 100,
acceleration = .05
}

and i wanted to add another property to their data like “weight”,
players with old data wouldn’t have that property, causing errors.

How would I get around this?

1 Like

When you load their data, iterate the default data table and set any keys and values the player’s data did not have.

1 Like

You can loop around your data table then use findfirstchild for (data[i]) (which should be the name of the property), by doing that you’re only getting the data that’s already stored, then when the player leaves or the data store saves you add the new property as you would normally. Hope this helps :slight_smile:

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.