So the problem I’m having is that my DataStore is not loading any data. It’s giving me an error that says:
ServerScriptService.*script*:188: invalid argument #3 (string expected, got nil)
-- === DataStorageStats[i].Value = DataStore:GetAsync(DataStorageStats[i].Name) as you see later.
My datastore script looks like this:
game.Players.PlayerAdded:Connect(function(Player)
local DataStore = DataStoreService:GetDataStore(Player.UserId .. "Data")
local DataStorageStats = Player.Data.Stats:GetChildren()
local DataStorageSettings = Player.Data.Settings:GetChildren()
if Player:WaitForChild("Data") ~= nil then
local success, result = pcall(function()
for i = 1, #DataStorageStats do
DataStorageStats[i].Value = DataStore:GetAsync(DataStorageStats[i].Name)
end
for i = 1, #DataStorageSettings do
DataStorageSettings[i].Value = DataStore:GetAsync(DataStorageSettings[i].Name)
end
end)
if success then
print("Loaded!")
Player.Data.Loaded.Value = true
else
print("No!!!!")
warn(result)
end
end
end)
What I want my script to do is save the data from the settings and the stats.
One thing I think could be the problem is that DataStorageStats[i].Value
is not true
/is not equal to anything, obviously I did add data to them as they are folders. The other thing is that it is trying to call it with the for
loop for too long???