I used the example Datastore code as a foundation, but I noticed that if you ever want to add or remove values from the retrieved data that it get's a little tricky. Ex.

sessionData[player] = {SBBplayerSettings = {apples= false, toOranges= false}, pearsAreOktoo = false}

When a new player joins, their data will be created to have this setup. However, if a player had joined before the update, when retrieving their data it may look more like this:

sessionData[player] = {"Experience" = 0, "Money" = 0}

I have no idea how to pull the old strings/tables and convert them to the updated format. I have however tried something like this (there is code before this that worked at figuring out which pieces are missing which is not included)

if firstTimeEntry == false then

for key,value in pairs(dataWork) do -- dataWork is the table (dataWork = {data})

	--(I moved it to the table dataWork in order for it to run smoother.)

	for keyA,valueA in pairs(value) do -- My attempt to add a key to data inside dataWork

		firstTimeEntry = true

		print("made it to the table")

		table.insert(value, firstTimeEntry)

		print("made it past")

		firstTimeEntry = true

		print(keyA,"=",valueA)

	end

end

end

6 comments

0

Just for clarity I don't want to completely throw away all of their player data. I'm just adding/removing feaures all the time and need the system to be dynamic/

0

Your table data is a key value, why are you using table.insert? Simply set the keys value to add or remove that key

0

Oh duh. I tend to overcomplicate things. Thank you!

0

You could set the version of the data, and keep older data checking methods and when you save that player's data, just update it to the latest version.

0

Ah so you mean like have a seperate value in the datastore and check it's version that way? That could work, but at this point i'm 1000+ players in and would have to create the variable.

0

Wait do either of you have a little clip of example code? I tryed reconfiguring what I had and studio crashed. @hiimgoodpack @kingdom5