Adding a new array into an old datastore

This question is very similar to this thread, but the answer seems a bit overcomplicated for what I’m attempting to do. I could be mistaken.

How would I check and apply this change to any older player saves?

Old Datastore:

local DefaultData = {
    Test = {
		Head = 0, 
    },
}

New Datastore:

local DefaultData = {
    Test = {
		Head = 0, 
    },

	Maps = {
		Standard = true,
	},
}

Here’s what I’ve attempted (setting the players data when they first join):

if(Data.Maps == nil) then
    table.insert(Data, DefaultData.Maps)
end

table.insert adds a value to an array, not a dictionary.

To create a new dictionary value all you have to do is define it:


if Data.Maps==nil then
    Data.Maps = { --your table or value
        
    }
end

2 Likes

I am such a robot tonight. I made that way more complicated than I needed to. Thanks!

1 Like