Yes, there are numerous threads on this on here, and yes I've looked at about all off them but none of them are in the same situation as mine.
In my situation, the strings are being made with specific names as the player is playing. I've just got a folder in workspace called Inventory with folders in it with the names of each player online. Whenever something gets added a string gets made & added to the players folder
with the correct name. All I need to save & load are the names of each of the strings, not the values.
I'm an absolute noob at datastores and I just don't fully get this. I've looked at a crap ton of wiki pages, scriptinghelpers posts, a reddit post and other things and adapted my code but I just don't fully get it just yet. None of them explain in good detail what I'm confused at.
Here's what I have,
local Players = game:GetService("Players") local ServerStorage = game:GetService("Workspace") local DataStoreService = game:GetService("DataStoreService") local DataStore = DataStoreService:GetDataStore("Inventory") Players.PlayerAdded:Connect(function(player) print("Player") local folder = Instance.new("Folder") folder.Parent = ServerStorage.Inventory folder.Name = (player.Name) local PlayerData = DataStore:GetAsync(player.UserId) for i, v in pairs(PlayerData) do local value = Instance.new("StringValue") value.Name = v value.Parent = folder end end) local function playerLeaving(player) local inv = {} for i, v in pairs(ServerStorage.Inventory:FindFirstChild(player.Name):GetChildren()) do table.insert(inv, v.Name) end DataStore:SetAsync(player.UserId, inv) ServerStorage.Inventory:FindFirstChild(player.Name):Destroy() end game.Players.PlayerRemoving:Connect(playerLeaving) game:BindToClose(function() for _, player in pairs(game.Players:GetPlayers()) do playerLeaving(player) end end)
When the player rejoins it supposedly should take all of the string values out of the table and create strings for each one renamed to the appropriate title and put in the players folder.
Not really getting any errors, it just doesn't work.
However, I am getting this in console
17:22:03.523 - DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key = (an 8 digit string of numbers)
I'm mostly confused at loading all of the values when the player joined. Haven't seen anyone explain that really anywhere.
EDIT : I fixed 1 wrong line, tried in a live-game, still doesn't work. However, I added a print between lines 15 & 16 that looks like
print(v.Name.." Loaded")
And it comes up as attempt to concatenate nil with string
I added 1 correction edited onto main question and was told it would work if I tried it in a main-server game, which was true for some bits, it really just needed some fiddling.