For some reason only the money instance is being created. Does anyone know why? Thanks.
local ds = dss:GetDataStore("1")
game.Players.PlayerAdded:Connect(function(player)
playerKey = "Player_"..player.UserId
local data = ds:GetAsync(playerKey.."data")
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local otherstats = Instance.new("Folder")
otherstats.Name = "otherstats"
otherstats.Parent = player
local money = Instance.new("IntValue")
money.Parent = leaderstats
money.Name = "Money"
money.Value = data.money or 0
local level = Instance.new("IntValue")
level.Parent = leaderstats
level.Name = "Level"
level.Value = data.level or 1
local exp = Instance.new("IntValue")
exp.Parent = leaderstats
exp.Name = "Exp"
exp.Value = data.exp or 100
local income = Instance.new("IntValue")
income.Parent = leaderstats
income.Name = "Income"
income.Value = data.income or 0
local mg1 = Instance.new("IntValue")
mg1.Parent = otherstats
mg1.Name = "mg1"
mg1.Value = data.mg1 or 0
local mg10 = Instance.new("IntValue")
mg10.Parent = otherstats
mg10.Name = "mg10"
mg10.Value = data.mg10 or 0
local mg100 = Instance.new("IntValue")
mg100.Parent = otherstats
mg100.Name = "mg100"
mg100.Value = data.mg100 or 0
local mg1k = Instance.new("IntValue")
mg1k.Parent = otherstats
mg1k.Name = "mg1k"
mg1k.Value = data.mg1k or 0
local mg10k = Instance.new("IntValue")
mg10k.Parent = otherstats
mg10k.Name = "mg10k"
mg10k.Value = data.mg10k or 0
local mg100k = Instance.new("IntValue")
mg100k.Parent = otherstats
mg100k.Name = "mg100k"
mg100k.Value = data.mg100k or 0
data = {
money = money.Value;
level = level.Value;
exp = exp.Value;
income = income.Value;
mg1 = mg1.Value;
mg10 = mg10.Value;
mg100 = mg100.Value;
mg1k = mg1k.Value;
mg10k = mg10k.Value;
mg100k = mg100k.Value
}
function updateStats()
ds:SetAsync(playerKey.."data", data)
print("Updated")
end
while true do
wait(1)
money.Value = money.Value + 1
end
money.Changed:Connect(function()
if money.Value > exp.Value then
level.Value = level.Value + 1
exp.Value = exp.Value * 1.2
print("money is greater than exp")
end
end)
end)
game.Players.PlayerRemoving:Connect(updateStats)```