Save data just not loading

I’m creating a system to save and load a player’s weapons. It also needs to save stats about a weapon. Currently, I’m very, very close to a successful system, HOWEVER, I just can’t get the last little it to work.

LOADING:

		for i, v in pairs(WeaponsToLoad) do
		if v[1] ~= "Basic Sword" then
			local Weapon = game.ServerStorage.Weapons:FindFirstChild(v[1])
			if Weapon ~= nil then
				local personalWep = Weapon:Clone()
				personalWep.Parent = p.Inventory.Weapons
				personalWep.weaponStats.BaseDamage.Value = v[2]
				personalWep.weaponStats.Level.Value = v[3]
				personalWep.weaponStats.Rarity.Value = v[4]
				personalWep.weaponStats.WeaponValue.Value = v[5]
			end
		end
	end

SAVING:

	for i, v in pairs(p.Inventory.Weapons:GetChildren()) do
		local subTable = {}
		subTable[1] = v.Name
		subTable[2] = v.weaponStats.BaseDamage.Value
		subTable[3] = v.weaponStats.Level.Value
		subTable[4] = v.weaponStats.Rarity.Value
		subTable[5] = v.weaponStats.WeaponValue.Value
		table.insert(WeaponTable, i, subTable)
	end

WHAT IS DRIVING ME INSANE:

When loading data, it can find the name of the weapon from the table and successfully load it into the player’s inventory. I’ve printed the length of the loaded table, and it’s 5, like it should be. I’ve printed the values it is saving, and they’ve all been accurate. BUT WHEN ACTUALLY LOADING VALUES, such as v[3], it loads back to the default value.

FOR INSTANCE:

I save a weapon called “Mace”. I upgrade its level from 1 to 15 during gameplay. When loading back in, it reverts to 1. BUT the weapon still loads into inventory, meaning it’s just v[2]-v[5] that aren’t loading, and I cannot for the life of me, figure out why.

1 Like

Is WeaponTable (from the save loop) the array that is passed as WeaponsToLoad in the loading loop?

Yes, it is.

Like I said, it’s successfully saving and reading some of the data. Like it can read the name (saved in v[1]) and successfully clone it, but it can’t save/read v[2]-v[5] for some reason.

It’s fixed. I think it had something to do with testing in Roblox Studio (even with Studio Access to API Services turned on)

When tested in an actual game, after a minor tweak or two, it worked.

2 Likes

Are you, by any chance, in a team create? If so, this is a known bug which is incredibly annoying.

Otherwise, turning on API access should be enough.

2 Likes