I have 3 values, Gold EXP Level, none of them are saving?!?!?!?
I get no errors!
Help!
local DataStore = game:GetService("DataStoreService")
local Usersave = DataStore:GetDataStore("UserSaver")
game.Players.PlayerAdded:connect(function(plr)
local key = "player-" ..plr.userId
local stat = Instance.new("IntValue", plr)
stat.Name = "leaderstats"
--Gold
local Gold = Instance.new("IntValue", stat)
Gold.Name = "Gold"
Gold.Value = 0
--EXP
local EXP = Instance.new("IntValue", stat)
EXP.Name = "EXP"
EXP.Value = 0
--Level
local Level = Instance.new("IntValue", stat)
Level.Name = "Level"
Level.Value = 0
EXP.Changed:connect(function()
Level.Value = math.floor(EXP.Value/1000 * math.random(1, 5))
end)
local GetSaved = Usersave:GetAsync(key)
if GetSaved ~= nil then
local SavingValues = {Gold.Value, EXP.Value, Level.Value}
Usersave:SetAsync(key, SavingValues)
print("Data found!")
elseif GetSaved ~= nil then
print("data wasn't found!")
local SavingValues2 = {Gold.Value, EXP.Value, Level.Value}
Usersave:SetAsync(key, SavingValues2)
end
end)
game.Players.PlayerRemoving:connect(function(plr)
print("saving data!")
local key = "player-"..plr.userId
local ValuesToSave = {plr.leaderstats.EXP.Value, plr.leaderstats.Level.Value, plr.leaderstats.Gold.Value}
Usersave:SetAsync(key, ValuesToSave)
end)
