Do nested tables lose values if you send them into a data store

im making a saving system to save neural networks, and they have their layers, neurons, biases, connections, etc, saved inside of nested tables inside of nested tables.

i’ve written 2 scripts that save and load the neural networks, and they SEEM to have nothing wrong with them. the issue is, what gets loaded is not what i saved, so its either saving didnt save everything, or loading did load everything.

SAVING SCRIPT:

local datastoreService = game:GetService("DataStoreService")
local NetworkSave = datastoreService:GetDataStore("Network")

print(NetworkSave:GetAsync("Network"))

local BestNetwork = require(game.ServerScriptService.BestNetwork)

script.Parent.MouseButton1Click:Connect(function()
	print(BestNetwork.BestNetwork)
	NetworkSave:SetAsync("Network",BestNetwork.BestNetwork)
end)

LOADING SCRIPT:

local datastoreService = game:GetService("DataStoreService")
local NetworkSave = datastoreService:GetDataStore("Network")

local BestNetwork = require(game.ServerScriptService.BestNetwork)

script.Parent.MouseButton1Click:Connect(function()
	local NewNetwork = NetworkSave:GetAsync("Network")
	BestNetwork.BestNetwork = NewNetwork
	
	print(NewNetwork)
	
	game.ServerScriptService.TeachingScript.Enabled = false
	wait(0.5)
	game.ServerScriptService.TeachingScript.Enabled = true
end)

The only way that I know of that you’ll lose information when saving data is if the table or any of the nested tables is a mixed table. In that case, I believe the string keys will be dropped from that table when saving to the data store.

I’d double check that that isn’t the case with your tables.

1 Like

this is exactly what happened, are there any workarounds?

I think u should use datastore2 if u need to use strings

Either convert all your numeric keys to string keys right as you’re about to save the table or structure your tables to avoid mixed tables altogether.

I recommend the latter. Unless the table you’re trying to save is super complex, it shouldn’t be too difficult to restructure it.

1 Like

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