Datastores to save Dictionairies

Try running this

for i,v in next, user.Classes do
print(i,v)
if type(v) == 'table' then
for i,v in next, v do
print('\t',i,v)
end
end
end
 Archer table: 382A7B60
  	 Weapons table: 382A7D40
  	 Trails table: 382A7D70
  	 Armours table: 382A7E00
  EquippedArcher table: 382A77D0
  	 Trail None
  	 Armour Archer Armour
  	 Weapon Bow and Arrow
  Knight table: 382A7920
  	 Weapons table: 382A7950
  	 Trails table: 382A7BF0
  	 Armours table: 382A80D0
  EquippedKnight table: 382A78F0
  	 Trail None
  	 Armour Knight Armour
  	 Weapon Classic Sword

Not sure why the EquippedKnight and EquippedArcher are there as they are in there own table

Classes = {
	['Knight'] = { -- Knight
		['ID'] = 1,
		['Owned'] = true,
		['Weapons'] = {
			'Classic Sword',
		},
		['Armours'] = {
			'Knight Armour'
		},
		['Trails'] = {
			'None'
		},
	},
	['Archer'] = {	-- Archer
		['ID'] = 2,
		['Owned'] = true,
		['Weapons'] = {
			'Bow and Arrow'
		},
		['Armours'] = {
			'Archer Armour'
		},
		['Trails'] = {
			'None'
		},
	},
},

ClassEquips = {
	EquippedKnight = {
		Weapon = 'Classic Sword', 
		Armour = 'Knight Armour', 
		Trail = 'None'
	},
	EquippedArcher = {
		Weapon = 'Bow and Arrow', 
		Armour = 'Archer Armour', 
		Trail = 'None'
	},
},

EDIT OMG, the problem was the data store! I had it set to

local playerDataStore = dataStoreService:GetDataStore('PlayerDataStore', 'Test01')

Which Test01 had saved a completely different classData table :man_facepalming:
Far out I am sorry, I feel incredibly stupid right now

Can you try this

for i,v in next, user.Classes.Archer do
print(i,v)
if type(v) == 'table' then
for i,v in next, v do
print('\t',i,v)
end
end
end
for i,v in next, user.Classes.EquippedArcher do
print(i,v)
if type(v) == 'table' then
for i,v in next, v do
print('\t',i,v)
end
end
end

I suspect that the EquippedArcher was once saved on the datastore and is causing this problem now.

Just fixed it

Everything works… for now :sweat_smile:

Pretty sure there will be problems when it comes time to add in another class however. Would be ok for newer players, but since older players would already have a datastore, it’d load from their old data store, skipping that class out…?

For example, adding this into the table:

['Scout'] = {
			['ID'] = 3,
			['Owned'] = false,
			['Weapons'] = {
				'Dagger'
			},
			['Armours'] = {
				'Scout Armour'
			},
			['Trails'] = {
				'None'
			},
		},

Would be fine for new players, as theyd start their data from this default table, but the players with a datastore already wouldnt acquire this new section their data??

You need to create a function that checks the changes on the old to new data and then add it to the old data

…rip

Do you think you could have a look at this if you have some spare time? Long thread, could probs just read the OP and last few comments, but yeah, struggeling to comprehend what’s wrong