okay here it is
local ds = game:GetService(“DataStoreService”):GetDataStore(“StatsSave”)
game.Players.PlayerAdded:Connect(function(player)
local stats = Instance.new(“Folder”, player)
stats.Name = “leaderstats”
local map = Instance.new(“Folder”, player)
map.Name = “mapstats”
local coins = Instance.new("IntValue", stats)
coins.Name = "Coins"
local power = Instance.new("IntValue", stats)
power.Name = "Junk"
local maps = Instance.new("IntValue", map)
maps.Name = "Maps"
local rank = Instance.new("StringValue", stats)
rank.Name = "Rank"
local item = Instance.new("StringValue", map)
item.Name = "itemowned"
local space = Instance.new("NumberValue", player)
space.Name = "capacity"
local level = Instance.new("IntValue", player)
level.Name = "Level"
local expMax = Instance.new("IntValue", level)
expMax.Name = "Max"
local exp = Instance.new("IntValue", level)
exp.Name = "XP"
local owned = Instance.new("IntValue", map)
owned.Name = "items"
local gem = Instance.new("NumberValue", map)
gem.Name = "Gems"
exp.Changed:Connect(function(val)
if exp.Value >= expMax.Value then
level.Value = level.Value + 1
exp.Value = 0
expMax.Value = expMax.Value * 1.2
end
end)
–[[power.Changed:Connect(function(val)
if power.Value >= space.Value then
power.Value = space.Value
end
end)
–]]
local store = ds:GetAsync(player.UserId)
if store ~= nil then
coins.Value = store[1]
power.Value = store[2]
maps.Value = store[3]
rank.Value = store[4]
item.Value = store[5]
space.Value = store[6]
level.Value = store[7]
expMax.Value = store[8]
exp.Value = store[9]
owned.Value = store[10]
gem.Value = store[11]
else
coins.Value = 0
power.Value = 0
maps.Value = 0
rank.Value = "Rookie Janitor"
item.Value = "Item0"
space.Value = 25
level.Value = 1
expMax.Value = 100
exp.Value = 0
owned.Value = 0
gem.Value = 0
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local save = {}
table.insert(save, player.leaderstats.Coins.Value)
table.insert(save, player.leaderstats.Junk.Value)
table.insert(save, player.mapstats.Maps.Value)
table.insert(save, player.leaderstats.Rank.Value)
table.insert(save, player.mapstats.itemowned.Value)
table.insert(save, player.capacity.Value)
table.insert(save, player.Level.Value)
table.insert(save, player.Level.Max.Value)
table.insert(save, player.Level.XP.Value)
table.insert(save, player.mapstats.items.Value)
table.insert(save, player.mapstats.Gems.Value)
ds:SetAsync(player.UserId, save)
end)