Im trying to save values that i have currently in workspace, i dont want to make leaderstats because it is kinda wierd, and its a solo game. this is my current code:
local ds = game:GetService("DataStoreService"):GetDataStore("SaveData")
game.Players.PlayerAdded:Connect(function(plr)
wait()
local plrkey = "id_"..plr.userId
local save1 = workspace.Apple.Value
local save2 = workspace.Birch.Value
local save3 = workspace.Hatchet.Value
local save4 = workspace.Iron.Value
local save5 = workspace.Leaf.Value
local save6 = workspace.Matchet.Value
local save7 = workspace["Oak Tree"].Value
local save8 = workspace.Stick.Value
local save9 = workspace.Stone.Value
local save10 = workspace.Sulphur.Value
local save11 = workspace.Wood.Value
local save12 = workspace.ChestLoot.Diamond.Value
local save13 = workspace.ChestLoot.Emerald.Value
local save14 = workspace.ChestLoot.Glass.Value
local save15 = workspace.ChestLoot.Gold.Value
local save16 = workspace.ChestLoot.Pearl.Value
local save17 = workspace.ChestLoot.Platnum.Value
local save18 = workspace.ChestLoot.Ruby.Value
local save19 = workspace.ChestLoot.Sapphire.Value
local save20 = workspace.ChestLoot.Scrap.Value
local GetSaved = ds:GetAsync(plrkey)
if GetSaved then
save1 = GetSaved[1]
save2 = GetSaved[2]
save3 = GetSaved[3]
save4 = GetSaved[4]
save5 = GetSaved[5]
save6 = GetSaved[6]
save7 = GetSaved[7]
save8 = GetSaved[8]
save9 = GetSaved[9]
save10 = GetSaved[10]
save11 = GetSaved[11]
save12 = GetSaved[12]
save13 = GetSaved[13]
save14 = GetSaved[14]
save15 = GetSaved[15]
save16 = GetSaved[16]
save17 = GetSaved[17]
save18 = GetSaved[18]
save19 = GetSaved[19]
save20 = GetSaved[20]
else
local NumberForSaving = {save1.Value, save2.Value, save3.Value, save4.Value, save5.Value, save6.Value, save7.Value, save8.Value, save9.Value, save10.Value, save11.Value11, save12.Value, save13.Value, save14.Value, save15.Value, save16.Value, save17.Value, save18.Value, save19.Value, save20.Value, }
ds:GetAsync(plrkey, NumberForSaving)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
ds:SetAsync("id_"..plr.userId,
{
workspace.Apple.Value,
workspace.Birch.Value,
workspace.Hatchet.Value,
workspace.Iron.Value,
workspace.Leaf.Value,
workspace.Matchet.Value,
workspace["Oak Tree"].Value,
workspace.Stick.Value,
workspace.Stone.Value,
workspace.Sulphur.Value,
workspace.Wood.Value,
workspace.ChestLoot.Diamond.Value,
workspace.ChestLoot.Emerald.Value,
workspace.ChestLoot.Glass.Value,
workspace.ChestLoot.Gold.Value,
workspace.ChestLoot.Pearl.Value,
workspace.ChestLoot.Platnum.Value,
workspace.ChestLoot.Ruby.Value,
workspace.ChestLoot.Sapphire.Value,
workspace.ChestLoot.Scrap.Value,
})
end)
when i leave and rejoin the values dont save, its on a local script, i have no idea on how to fix it