Saving table, only saves key names not values

It only saves the names of the keys without their values ({HasPlayed} instead of {HasPlayed} = true

this is the module function for when a value changes

function playerModule:ValueChanged(player, value)
	print("module script")
	print(playerModule[player.Name])
	table.insert(playerModule[player.Name], value.Name)
	task.wait()
	playerModule[player.Name][value.Name] = value.Value
	print("added to table!")
	print(playerModule.toUpdate)
end

server script save function:

function dataSave(player)
	print(moduleScript[player.Name]) --- this prints {HasPlayed} = true, [1]HasPlayed
	local playerTable = moduleScript[player.Name]
	
	local success, err = pcall(function()
		mystore:SetAsync(player.UserId .. "_" .. key, playerTable)
	end)
	if success then
		print("data saved!")
		if not player then
			local updateModule = require(game.ReplicatedStorage:FindFirstChild("UpdateData"))
			task.wait()
			table.clear(moduleScript[player.Name])
			print("table cleared!")
		else
			local updateModule = require(game.ReplicatedStorage:FindFirstChild("UpdateData"))
			task.wait()
			table.clear(moduleScript[player.Name])
			print("table cleared!")
			local GetPlayerData = mystore:GetAsync(player.UserId .. "_" .. key)
			print(GetPlayerData) --- supposed to print same as first print, but instead prints {HasPlayed}
		end
	else
		print("data failed to save..." .. err)
	end
end
1 Like

Can you please show the code you are using to save?

1 Like

Yes so I actually fixed that, but now it only saves the names of the keys without their values ({HasPlayed} instead of {HasPlayed} = true

this is the module function for when a value changes

function playerModule:ValueChanged(player, value)
	print("module script")
	print(playerModule[player.Name])
	table.insert(playerModule[player.Name], value.Name)
	task.wait()
	playerModule[player.Name][value.Name] = value.Value
	print("added to table!")
	print(playerModule.toUpdate)
end

server script save function:

function dataSave(player)
	print(moduleScript[player.Name]) --- this prints {HasPlayed} = true, [1]HasPlayed
	local playerTable = moduleScript[player.Name]
	
	local success, err = pcall(function()
		mystore:SetAsync(player.UserId .. "_" .. key, playerTable)
	end)
	if success then
		print("data saved!")
		if not player then
			local updateModule = require(game.ReplicatedStorage:FindFirstChild("UpdateData"))
			task.wait()
			table.clear(moduleScript[player.Name])
			print("table cleared!")
		else
			local updateModule = require(game.ReplicatedStorage:FindFirstChild("UpdateData"))
			task.wait()
			table.clear(moduleScript[player.Name])
			print("table cleared!")
			local GetPlayerData = mystore:GetAsync(player.UserId .. "_" .. key)
			print(GetPlayerData) --- supposed to print same as first print, but instead prints {HasPlayed}
		end
	else
		print("data failed to save..." .. err)
	end
end
1 Like