How would I make this script load the 3 datas when a player dies but keep it for 3 new values?
local ds = game:GetService("DataStoreService"):GetDataStore("Level")
game.Players.PlayerAdded:connect(function(player)
wait(player.CharacterAdded)
local expvalue = player.ExpValue
local gold = player.Gold
local lvlvalue = player.LvlValue
local expkey = 'expuser_'..(player.userId)
local goldkey = 'golduser_'..(player.userId)
local lvlkey = 'lvluser_'..(player.userId)
expvalue.Value = ds:GetAsync(expkey)
gold.Value = ds:GetAsync(goldkey)
lvlvalue.Value = ds:GetAsync(lvlkey)
if lvlvalue.Value == 0 or nil then lvlvalue.Value = lvlvalue.Value+1 end
if gold.Value == 0 or nil then gold.Value = 1 wait(.1) gold.Value = 0 end
if expvalue.Value == 0 or nil then expvalue.Value = 1 wait(.1) expvalue.Value = 0 end
expvalue.Changed:connect(function()
ds:SetAsync(expkey, (player.ExpValue.Value))
end)
gold.Changed:connect(function()
ds:SetAsync(goldkey, (player.Gold.Value))
end)
lvlvalue.Changed:connect(function()
ds:SetAsync(lvlkey, (player.LvlValue.Value))
end)
end)