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.
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.
Alright will do ill get back to you in sec.
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?
The data should transfer fine if:
- Each seperate place you want the data to be able to transfer to is under the same experience
- You are saving data on
PlayerRemoving
and loading it onPlayerAdded
- The game has enough time to save the data
- 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…
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?
Cool. Can you add the PlayerAdded
data loading function
as well please?
Absolutely that must’ve gone straight over my head, thank you for putting up with me works like a charm now
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.
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
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.