it loads but nothing saves when I'm in a server
local main = require(game.ServerScriptService.Main)
game.Players.PlayerAdded:Connect(function(player)
main.GiveStats(player)
end)
game.Players.PlayerRemoving:Connect(function(player)
main.SaveStats(player)
end)
Module script:
function Main.GiveStats(player)
local datastore = game:GetService("DataStoreService")
local leaderstats = Instance.new("IntValue")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Ores = Instance.new("Folder", player)
Ores.Name = "Ores"
local points = Instance.new("IntValue", leaderstats)
points.Name = "Cash"
local Pickaxes = Instance.new("Folder", player)
Pickaxes.Name = "Pickaxes"
local key = player.userId
local Blacklist = Instance.new("Folder", player)
Blacklist.Name = "Blacklist"
local ls = datastore:GetOrderedDataStore("CashSaveSystem"):GetAsync(key)
for i = 1, #Main.Ores do
if datastore:GetOrderedDataStore(Main.Ores[i]):GetAsync(key) then
local Item = Instance.new("IntValue", Ores)
Item.Name = Main.Ores[i]
Item.Value = datastore:GetOrderedDataStore(Main.Ores[i]):GetAsync(key)
end
end
if ls then
points.Value = ls
end
Main.GivePlayerTycoon(player)
end
function Main.SaveStats(plr)
local key = plr.UserId
local ds = game:GetService("DataStoreService")
for i,v in pairs(plr.Ores:GetChildren()) do
ds:GetOrderedDataStore(v.Name):SetAsync(key, v.Value)
end
local ls = plr.leaderstats.Cash.Value
ds:SetAsync(key, ls)
end

3 comments
If you provided the module script, it would help a lot.
theres alot of stuff but ok
done