Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Argument 1 missing or nil + Efficiency?

Asked by 10 years ago

I get this error: Argument 1 missing or nil? (Line 14) Storage[i].Value = DataStore:GetAsync(Storage[i].Name)

How could i make this more efficient, please someone help me. I been working all day on this literally!

local DataStore = Game:GetService("DataStoreService"):GetDataStore("Storage")
Storage = {
"KOS", 
"WOS", 
"Cash", 
"Rank", 
"XP",
}

Game.Players.PlayerAdded:connect(function(Player)
ypcall(function() repeat wait() until Player:FindFirstChild("leaderstats") end)
for i=1, #Storage do
if DataStore ~= nil then
Storage[i].Value = DataStore:GetAsync(Storage[i].Name)
end
end
end)

Game.Players.PlayerRemoving:connect(function(Player)
for i=1, #Storage do
Storage[i].Value = DataStore:SetAsync(Storage[i].Name, Storage[i].Value)
end
end)

Answer this question