Error while loading datastore? [SOLVED]

The key used to access would be the line tostring(Player.UserId). Did the print() statement work?

Also, the FindFirstChild() part within the SetAsync() function needs to be changed. FindFirstChild() should be used when you are unsure whether something exists or not. Since it is a server-side script, change it to the following:

local playerPoints = player.Points.Value
local succ, err = pcall(function()
    Points:SetAsync(tostring(Player.UserId), playerPoints)
end)

Plus, if you are only testing this in Studio, your BindToClose() function is ignoring that which could still mean there’s not enough time for saving the data.

1 Like

Not at all, every time I have tried to test it and my print statements never print anything but "print("Loaded data of “…tostring(Player.Name))”, I have a few tostring lines for certain different datastores, such as banned players, play time, and points. The thing that gets printed says that the data is loaded, even when it is not. I publish after editing the script, and go on to the games page on the website and run it from there, and the same issue happens.

Try getting rid of the FindFirstChild() functions, and replace them with the code I sent above. Let me know how it goes.

1 Like

Alright will do ill get back to you in sec.

1 Like

That seems to be working great! Thank you! My data now loads, which is good progress, but I still seem to have issues while moving throughout places, my data doesn’t save withing place to place, I reset character to get a WO in the other place and it doesn’t save over, any idea how I can achieve this? I mean my KOs and WOs should move from the game under the starter place, and transfer the data over to the start place (the hub) so that it can calculate the KOs and WOs and convert them into points. Is it as simple as copying the script from serverscriptservice and placing it in the other places serverscriptservice?

1 Like

The data should transfer fine if:

  1. Each seperate place you want the data to be able to transfer to is under the same experience
  2. You are saving data on PlayerRemoving and loading it on PlayerAdded
  3. The game has enough time to save the data
  4. You are accessing the same DataStore within each place

I may have jumped the gun a bit asking that question so soon, so is that as simple as just copying over the main script from serverscriptservice where all the datahandlers are stored. Also it seems another error has popped up…
image

1 Like

Is that the same Points DataStore?

I’m fairly certain it is, i replaced all of the FindFirstChild() functions with what you provided. I’m starting to believe that I cant teleport while the data is this way

Would you mind sending a code snippet of the code you are using to get the data?

Sure thing, I assume this is what you’re asking about? I may be wrong

Cool. Can you add the PlayerAdded data loading function as well please?

1 Like

Absolutely that must’ve gone straight over my head, thank you for putting up with me works like a charm now :sob:

1 Like

Wouldn’t it be more efficient to store all the data in a dictionary instead of managing 50 trillion DataStores?

Probably, but once its done its done and I wont have to worry about it I suppose.

It would prevent requests from stacking up, which might result in some data not being saved.

1 Like

Using SetAsync 50 times may lead to datastore issues, hitting rate limits. It’s better to utilize a single DataStore and store the data in a dictionary. Additionally, consider using ProfileService to streamline the process and enhance efficiency.
Save your player data with ProfileService! (DataStore Module) - Resources / Community Resources - Developer Forum | Roblox

1 Like

Thank you ill check this out it should help out quite a bit in that sense.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.