Please I don’t ask for much. Just to know if from your knowledge I can improve my script and if so how? Otherwise is this script above likely to have data memoy problems ? thank you very much
I did have data loss issues initially in my game, which used a similar saving system as yours.
The solution that fixed all of these happened to be DataStore2, which you mentioned in your post. Is there any reason you want to avoid DataStore2?
Thank you for your answer
No particular reason, I just need to find out how it all works because I have never used this data. So you use two scripts, right? A datasave1 and a datasave2
I have read on the forum by many people that the use of the DataStore2 is not nearly as necessary as what is said everywhere. From the script above ? Someone could tell me how I could improve it. Thank you
A couple simple improvements to add could be:
- A way to delete saved data (For when you get a right-of-erasure-request from a player)
- Data store history to revert to last save version
- A retry method in case the datastore fails to retry getting the data
- A way to kick a player if the datastores fail, so they don’t override/lose previous data
Thank it make sense. All this can be done on the basis of my script without anything else? Or do I have to add modules and other things
Player kick seems to be good for you ? Do you know which module i have to add to data history, and why i have to delete data if a player resquet for ? Thank you. I really appreciate your help i need it
game.Players.PlayerAdded:Connect(function(player)
local folder = Instance.new("Folder")
folder.Name = "Creatures"
folder.Parent = player
local data
local success, errorMsg = pcall(function()
data = DataStore:GetAsync(player.UserId)
end)
local savedata = Instance.new("BoolValue", player)
savedata.Name = "SaveData"
savedata.Value = true
if success and data then
for _, cName in pairs(data) do
if workspace.Creatures:FindFirstChild(cName) then
local newval = Instance.new("BoolValue")
newval.Name = cName
newval.Parent = folder
print("data2")
else
print("no data2")
player.savedata.Value = false
player:Kick("Your data failed to load ! Please rejoin.")
end
end
end
end)
Well first off, you have to be able to delete player data because it’s an obligation under data protection laws. So you have to be able to delete all player records, and not just from your data stores.
Here is more information: About GDPR and CCPA
For data versioning, look under versioning here: Data Stores
But you could also do it a couple other ways. It’s really up to you
And yeah, your kick seems fine to me.
i add this line in playerAdded it seems to work :
local success, errorMsg = pcall(function()
while task.wait() do
wait(180)
saveData(player)
print("autosave")
end
end)
end)
One problem I still have is this. I understand that it is related to the fact that the server is overloaded with “GetAsync” or “SetAsync” requests (I forget), however I don’t know how to fix this problem with my script. Thank you very much
Everytime i leave the game i have this warning message
It’s because of the request limits on datastores. They scale to the amount of players in your game, but in studio because you playtest often, you’re hitting the limits. There is a way to check what your current request limit budget is though here: DataStoreService:GetRequestBudgetForRequestType
Thank you again for the time you take to me! however i’m pretty sur there is something wrong who create this warning message everytime (every every).
Anyway, do you know where i need to place the
“1. A retry method in case the datastore fails to retry getting the data” ?
On playerAdded ? PlayerRemoved ? BindToclose ? On the local function Data Save ? Everywhere ?
On the playerAdded. If your datastore getAsync returns false, then retry maybe 3 times. If it’s false all 3 times then kick the player.
Hey, Do you think line 87 ‘wait(“7”)’ can help to prevent from the warning message, or it is a very bad idea to do this ?
Edit : I think it is a bad idea since ok data4 and ok data3 dont show in the output when i leave
1 A retry method in case the datastore fails to retry getting the data → it’s OK
2 A way to kick a player if the datastores fail, so they don’t override/lose previous data → it’s OK
3 Data store history to revert to last save version → if someone can help me to achieve this please. I want to publish my game
i guess of putting game.Players each time u could use local Players = game:GetService('Players')
Yep, but does it make a difference in script ?
If anyone knows how to revert to the latest version of the data save a would be really great. Otherwise I won’t push it any further and will try to ask again in a few days. Thanks
no ur just making it shorter that way
You don’t seem to understand what DataStore2 actually is xD
Please read this:
You can also try using the ProfileService it has more features than DataStore2, but it’s up to you.