Datastore just isn’t working, I am lost
local DataStore = game:GetService("DataStoreService"):GetDataStore("StoreName")
game.Players.PlayerAdded:Connect(function(player)
local key = "key-"..player.userId
local folder = Instance.new("Folder", player)
folder.Name = "leaderstats"
local baseDamage = Instance.new("IntValue", folder)
baseDamage.Name = "BaseDamage"
local baseStrength = Instance.new("IntValue", folder)
baseStrength.Name = "BaseStrength"
local save = DataStore:GetAsync(key)
if save then
baseDamage.Value = save[1]
baseStrength.Value = save[2]
else
local load = {baseDamage.Value, baseStrength.Value}
DataStore:SetAsync(key,load)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local key = "key-"..player.userId
local load = {player.leaderstats:FindFirstChild("BaseDamage").Value, player.leaderstats:FindFirstChild('BaseStrength').Value}
--it stops here
DataStore:SetAsync(key,load)
end)