local DataStore = game:GetService("DataStoreService")
local ds1 = DataStore:GetDataStore("YumsSave")
local ds2 = DataStore:GetDataStore("BurgerSave")
local ds3 = DataStore:GetDataStore("Rebirthsave")
local ds4 = DataStore:GetDataStore("Petvaluesave")
local ds5 = DataStore:GetDataStore("PetSave")
local ds6 = DataStore:GetDataStore("PetSavevalue")
local ds7 = DataStore:GetDataStore("PetSavevalue2")
local ds8 = DataStore:GetDataStore("PetSavevalue3")
local ds9 = DataStore:GetDataStore("PetSavevalue4")
local ds10 = DataStore:GetDataStore("PetSavevalue5")
local ds11 = DataStore:GetDataStore("PetSavevalue6")
local try = 0
local waitt = 0
game.Players.PlayerAdded:connect(function(player)
local playerkey = player.UserId
print("stats")
local leader = Instance.new("Folder")
leader.Name = "leaderstats"
leader.Parent = player
local pet = Instance.new("NumberValue")
pet.Name = "petvalue"
pet.Parent = player
pet.Value = 0
print("pet value loaded")
local Yums = Instance.new("IntValue")
Yums.Name = "Yums"
Yums.Parent = leader
local w4, l4 = pcall(function()
Yums.Value = ds1:GetAsync(player.UserId)
ds1:SetAsync(player.UserId, Yums.Value)
end)
print("Yums loaded")
print(script.Parent)
local burger = Instance.new("IntValue")
burger.Name = "burger"
burger.Parent = leader
local w3, l3 = pcall(function()
burger.Value = ds2:GetAsync(player.UserId)
ds2:SetAsync(player.UserId, burger.Value)
end)
print("burger level loaded")
local rebirth = Instance.new("IntValue")
rebirth.Name = "Rebirth"
rebirth.Parent = leader
local w5, l5 = pcall(function()
rebirth.Value = ds3:GetAsync(player.UserId)
ds3:SetAsync(player.UserId, rebirth.Value)
end)
print("rebirths")
local pets = Instance.new("Folder")
pets.Name = "pets"
pets.Parent = leader
local petone = Instance.new("IntValue")
petone.Parent = pets
petone.Name = "one"
local w6, l6 = pcall(function()
petone.Value = ds6:GetAsync(player.UserId)
ds6:SetAsync(player.UserId, petone.Value)
end)
print("pet1 loaded")
local pettwo = Instance.new("IntValue")
pettwo.Parent = pets
pettwo.Name = "two"
local w7, l7 = pcall(function()
pettwo.Value = ds7:GetAsync(player.UserId)
ds7:SetAsync(player.UserId, pettwo.Value)
end)
print("pet2 loaded")
local petthree = Instance.new("IntValue")
petthree.Parent = pets
petthree.Name = "three"
local w8, l8 = pcall(function()
petthree.Value = ds8:GetAsync(player.UserId)
ds8:SetAsync(player.UserId, petthree.Value)
end)
print("pet3 loaded")
local petfour = Instance.new("IntValue")
petfour.Parent = pets
petfour.Name = "four"
local w9, l9 = pcall(function()
petfour.Value = ds9:GetAsync(player.UserId)
ds9:SetAsync(player.UserId, petfour.Value)
end)
print("pet4 loaded")
local petfive = Instance.new("IntValue")
petfive.Parent = pets
petfive.Name = "five"
local w10, l10 = pcall(function()
petfive.Value = ds10:GetAsync(player.UserId)
ds10:SetAsync(player.UserId, petfive.Value)
end)
print("pet5 loaded")
local petsix = Instance.new("IntValue")
petsix.Parent = pets
petsix.Name = "six"
local w11, l11 = pcall(function()
petsix.Value = ds11:GetAsync(player.UserId)
ds11:SetAsync(player.UserId, petsix.Value)
end)
print("pet6 loaded")
if w3 then
print("load succes")
end
if l3 then
warn(l3)
end
if w4 then
print("load succes")
end
if l4 then
warn(l4)
end
if w5 then
print("load succes")
end
if l5 then
warn(l5)
end
if w6 then
print("load succes")
end
if l6 then
warn(l6)
end
if w7 then
print("load succes")
end
if l7 then
warn(l7)
end
if w8 then
print("load succes")
end
if l8 then
warn(l8)
end
if w9 then
print("load succes")
end
if l9 then
warn(l9)
end
if w10 then
print("load succes")
end
if l10 then
warn(l10)
end
if w11 then
print("load succes")
end
if l11 then
warn(l11)
end
petone.Changed:Connect(function()
local w, l = pcall(function()
ds6:UpdateAsync(playerkey, function(oldvalue)
return player.leaderstats.pets.one.Value
end)
end)
if ds6:GetAsync(player.UserId, petone.Value) == petone.Value then
print("saved")
end
end)
pettwo.Changed:Connect(function()
local w, l = pcall(function()
ds7:UpdateAsync(playerkey, function(oldvalue)
return player.leaderstats.pets.two.Value
end)
end)
if ds7:GetAsync(player.UserId, pettwo.Value) == pettwo.Value then
print("saved")
end
end)
petthree.Changed:Connect(function()
local w, l = pcall(function()
ds8:UpdateAsync(playerkey, function(oldvalue)
return player.leaderstats.pets.three.Value
end)
end)
if ds8:GetAsync(player.UserId, petthree.Value) == petthree.Value then
print("saved")
end
end)
petfour.Changed:Connect(function()
local w, l = pcall(function()
ds9:UpdateAsync(playerkey, function(oldvalue)
return player.leaderstats.pets.four.Value
end)
end)
if ds9:GetAsync(player.UserId, petfour.Value) == petfour.Value then
print("saved")
end
end)
petfive.Changed:Connect(function()
local w, l = pcall(function()
ds10:UpdateAsync(playerkey, function(oldvalue)
return player.leaderstats.pets.five.Value
end)
end)
if ds10:GetAsync(player.UserId, petfive.Value) == petfive.Value then
print("saved")
end
end)
petsix.Changed:Connect(function()
local w, l = pcall(function()
ds11:UpdateAsync(playerkey, function(oldvalue)
return player.leaderstats.pets.six.Value
end)
end)
if ds11:GetAsync(player.UserId, petsix.Value) == petsix.Value then
print("saved")
end
end)
Yums.Changed:Connect(function()
local w, l = pcall(function(plr)
ds1:UpdateAsync(playerkey, function(oldvalue)
return player.leaderstats.Yums.Value
end)
end)
if ds1:GetAsync(player.UserId, Yums.Value) == Yums.Value then
print("saved")
end
end)
burger.Changed:Connect(function()
local w, l = pcall(function()
ds2:UpdateAsync(playerkey, function(oldvalue)
return player.leaderstats.burger.Value
end)
end)
if ds2:GetAsync(player.UserId, Yums.Value) == Yums.Value then
print("saved")
end
end)
rebirth.Changed:connect(function()
local w, l = pcall(function()
ds3:UpdateAsync(playerkey, function(oldvalue)
return player.leaderstats.Rebirth.Value
end)
end)
if ds3:GetAsync(player.UserId, rebirth.Value) == rebirth.Value then
print("saved")
end
end)
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
char.Changed:Connect(function()
if ds4:GetAsync(player.UserId, Yums.Value) == Yums.Value then
print("saved")
end
end)
end)
end)
end)
game.Players.PlayerRemoving:connect(function(player)
local w, l = pcall(function()
ds1:UpdateAsync(player.UserId, function(oldvalue)
return player.leaderstats.Yums.Value
end)
end)
if w then
print("load succes")
end
if l then
warn(l)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local w2, l2 = pcall(function()
ds2:UpdateAsync(player.UserId, function(oldvalue)
return player.leaderstats.burger.Value
end)
end)
if w2 then
print("load succes")
end
if l2 then
warn(l2)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local w3, l3 = pcall(function()
ds3:UpdateAsync(player.UserId, function(oldvalue)
return player.leaderstats.Rebirth.Value
end)
end)
if w3 then
print("load succes")
end
if l3 then
warn(l3)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local w4, l4 = pcall(function()
ds6:UpdateAsync(player.UserId, function(oldvalue)
return player.leaderstats.pets.one.Value
end)
end)
if w4 then
print("load succes")
end
if l4 then
warn(l4)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local w5, l5 = pcall(function()
ds7:UpdateAsync(player.UserId, function(oldvalue)
return player.leaderstats.pets.two.Value
end)
end)
if w5 then
print("load succes")
end
if l5 then
warn(l5)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local w6, l6 = pcall(function()
ds8:UpdateAsync(player.UserId, function(oldvalue)
return player.leaderstats.pets.three.Value
end)
end)
if w6 then
print("load succes")
end
if l6 then
warn(l6)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local w7, l7 = pcall(function()
ds9:UpdateAsync(player.UserId, function(oldvalue)
return player.leaderstats.pets.four.Value
end)
end)
if w7 then
print("load succes")
end
if l7 then
warn(l7)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local w8, l8 = pcall(function()
ds10:UpdateAsync(player.UserId, function(oldvalue)
return player.leaderstats.pets.five.Value
end)
end)
if w8 then
print("load succes")
end
if l8 then
warn(l8)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local w9, l9 = pcall(function()
ds11:UpdateAsync(player.UserId, function(oldvalue)
return player.leaderstats.pets.six.Value
end)
end)
print("saved")
if w9 then
print("load succes")
end
if l9 then
warn(l9)
end
end)
I already added updateasync by value changes instead of setasync and used pcall functions to dectect errors