So I'm currently trying to make a save data system, but whenever I do it it comes up with the error "Argument 1 missing or nil" on line 7 anyway to fix this?
local ds = game:GetService("DataStoreService"):GetDataStore("SaveData")
game.Players.PlayerAdded:Connect(function(plr, leaderstats)
local plrkey = "id_"..plr.userId
local save1 = plr:WaitForChild(leaderstats).Defense
local save2 = plr:WaitForChild(leaderstats).Power
local GetSaved = ds:GetAsync(plrkey)
if GetSaved then
save1.Value = GetSaved[1]
save2.Value = GetSaved[2]
else
local NumberForSaving = {save1.Value, save2.Value}
ds:GetAsync(plrkey, NumberForSaving)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
ds:SetAsync("id_"..plr.userId, {plr.leaderstats.Defense.Value, plr.leaderstats.Power.Value})
end)

1 comment
Sorry guys, I'm so fucking stupid I can't use my little brain.