here is my code,

local DS = game:GetService("DataStoreService") local moneyStore = DS:GetDataStore("Money")

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

local moneyValue
local success, err = pcall(function()
	moneyValue = moneyStore:GetAsync("Player_"..Player.UserId)
end)

local Stats = Instance.new('Folder',Player)
Stats.Name = 'leaderstats'
Stats.Parent = Player

local FLOOGOLS = Instance.new('IntValue',Stats)
FLOOGOLS.Name = ('FLOOGOLS')
FLOOGOLS.Parent = Stats

if success then
	FLOOGOLS.Value = moneyValue
else
	print("Failed to load playerdata")
end

end)

local fuction save(Player) local success, err = pcall(function() moneyStore:SetAsync("Player_"..Player.UserId, Player.leaderstats.money.value) end) if success then print("Saved data") else print("Failed to save") end

local function autosave() while wait (10) do for i, player in pairs(game:GetService("Players"):GetPlayers()) do save(player) end end end

spawn(autosave)

Here is the error,   15:21:24.610 ServerScriptService.Stats:27: attempt to call a nil value  -  Server  -  Stats:27

New to this, be nice!