DataStore tables not loading (Attempt to index number with 'Value')

So im trying to create a easy way to access a players datastore with the datastore editor looking like this:


And it works for now with making the data. But doesnt seem to load. (Saving works)

Script:

local serverStorage = game:GetService("ServerStorage")

local DataStore = game:GetService("DataStoreService"):GetDataStore("MainDataStore")

game.Players.PlayerAdded:Connect(function(player)

	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	local money = Instance.new("NumberValue")
	money.Name = "Money"
	money.Parent = leaderstats

	local ore = Instance.new("NumberValue")
	ore.Name = "Ore"
	ore.Parent = leaderstats

	local rebirths = Instance.new("IntValue")
	rebirths.Name = "Rebirths"
	rebirths.Parent = leaderstats

	local dataFolder = Instance.new("Folder")
	dataFolder.Name = player.Name
	dataFolder.Parent = serverStorage.RemoteData

	local debounce = Instance.new("BoolValue")
	debounce.Name = "Debounce"
	debounce.Parent = dataFolder

	local sellDebounce = Instance.new("BoolValue")
	sellDebounce.Name = "SellDebounce"
	sellDebounce.Parent = dataFolder

	local ownedTools = Instance.new("Folder",dataFolder)
	ownedTools.Name = "ownedTools"

	local corrodedShovel = Instance.new("BoolValue",ownedTools)
	corrodedShovel.Name = "corrodedShovel"

	local plasticShovel = Instance.new("BoolValue",ownedTools)
	plasticShovel.Name = "plasticShovel"

	local ID = "Player_"..player.UserId
	local savedData = nil
	--local data
	--local success, errormessage = pcall(function()
	--	data = DataStore:GetAsync(ID)
	--end)
	
	pcall(function()
		savedData = DataStore:GetAsync(ID)
	end)

	if savedData ~= nil then
		money.Value = savedData.Money.Value
		ore.Value = savedData.Ore.Value
		rebirths.Value = savedData.Rebirths.Value
		print("Data loaded")
	else
		money.Value = 50
		print("No data found (new save)")
	end

	wait(2)

	player.PlayerGui.CoreUi.MainFrame.DollaFrame.Value.Text = player.leaderstats.Money.Value
	player.PlayerGui.CoreUi.MainFrame.OreFrame.Value.Text = player.leaderstats.Ore.Value

	player.PlayerGui.CoreUi.ShopUi.ScrollingFrame.CorrodedShovel.prclickTxt.Text = player.PlayerGui.CoreUi.ShopUi.ScrollingFrame.CorrodedShovel.prclick.Value.." Ore per click!"
	player.PlayerGui.CoreUi.ShopUi.ScrollingFrame.CorrodedShovel.priceTxt.Text = player.PlayerGui.CoreUi.ShopUi.ScrollingFrame.CorrodedShovel.price.Value.."$"
	
end)

game.Players.PlayerRemoving:Connect(function(player)
	
	local ownedToolsSave = {}

	table.insert(ownedToolsSave, game.ServerStorage.RemoteData[player.Name].ownedTools.corrodedShovel.Value)
	table.insert(ownedToolsSave, game.ServerStorage.RemoteData[player.Name].ownedTools.plasticShovel.Value)
	
	local data = {
		["Money"] = player.leaderstats.Money.Value,
		["Ore"] = player.leaderstats.Ore.Value,
		["Rebirths"] = player.leaderstats.Rebirths.Value,
		["ownedTools"] = ownedToolsSave
	}
	
	local ID = "Player_"..player.UserId
	DataStore:SetAsync(ID,data)
end)

game:BindToClose(function()

	-- When game is ready to shutdown

	for i, player in pairs(game.Players:GetPlayers()) do
		if player then
			player:Kick("Game shutdown")
		end
	end

	wait(5)

end)

Error:

ServerScriptService.Script:56: attempt to index number with 'Value'

Line 56 is the loading part: money.Value = savedData.Money.Value

Can anyone help me?

You’re saving a dictionary with already value-set keys. There’s no “Value” property, so you just need to index the name.

	if savedData ~= nil then
		money.Value = savedData.Money
		ore.Value = savedData.Ore
		rebirths.Value = savedData.Rebirths
		print("Data loaded")
	else
		money.Value = 50
		print("No data found (new save)")
	end

Hello, you are indexing your database object with .Value, your database object returned a number, not an Instance, therefore you can’t iterate it with .Value. Instead use money.Value = databaseobject. Please leave me a like and if this helped mark this as a solution.