|
| 22 Nov 2017 04:21 PM |
I dont get it at all. This is how I set it up. I store data via number values in a folder named DATABAG. (This is basically a shortened edited version of how I save/load, there is no error, people just lose data sometimes)
ds = game:GetService("DataStoreService"):GetDataStore("States") function Save(p) if player.DATABAG ~= nil then ds:SetAsync("Stats" .. p.userId, { p.DATABAG.MONEY.Value, } end end function onPlayerAdded(player) if player.DATABAG == nil then script.DATABAG:Clone().Parent = player if ds:GetAsync("Stats" .. player.userId) then --- CHECKIN FOR DATA player.DATABAG.MONEY.Value = ds:GetAsync("Stats" .. player.userId)[1] end end end Players.PlayerAdded:connect(onPlayerAdded)
game:BindToClose(function() wait(5) end) -- in case of crashes
game.Players.PlayerRemoving:connect(function(player) if player:findFirstChild("DATABAG") ~= nil then Save(player) end end)
Now theres a lot more stuff im loading and saving and its not all quite named the same, but the issue isn't a typo or some error as I, or my alts, have never lost data and I have tried many times to glitch my game to erase my data, and i never have. It loads and saves smoothly for every instance i observe.
However, kids in my game are constantly messaging me they lost their data. I DONT KNOW HOW? Anyone have any clues at all?
I can pay if needed |
|
|
| Report Abuse |
|
|
|
| 22 Nov 2017 04:23 PM |
| Maybe those kids are lying for free things lol |
|
|
| Report Abuse |
|
|
|
| 22 Nov 2017 04:23 PM |
| If it throttles when they leave, will it fail to save or will it keep the player data until it can? |
|
|
| Report Abuse |
|
|
|
| 22 Nov 2017 04:24 PM |
| You should add an autosave feature. |
|
|
| Report Abuse |
|
|
|
| 22 Nov 2017 04:26 PM |
| I had an autosave before, it has something to do with accidently saving everything back to 0 I guess, doesnt make sense to me. I actually dont know what is wrong. |
|
|
| Report Abuse |
|
|
|
| 22 Nov 2017 04:27 PM |
| I don't see the problem either. |
|
|
| Report Abuse |
|
|
|
| 22 Nov 2017 04:30 PM |
I save like 100 things like that, via that style, manually.
Would that be the problem? Who knows. |
|
|
| Report Abuse |
|
|
|
| 22 Nov 2017 04:31 PM |
| Would a data throttle as the leave erase their data? |
|
|
| Report Abuse |
|
|
|
| 22 Nov 2017 04:32 PM |
| Do you have an error handling method using pcall? I read on the wiki that sometimes it fails due to poor web connectivity? |
|
|
| Report Abuse |
|
|
|
| 22 Nov 2017 04:37 PM |
I have no clue what a pcall is, but ive seen it around. Ill look into it, but i have 10k people playing atm and I cant just go rewrite my save/load system.
but poor web connectivity would basically mean they are getting unlucky at leaving at the wrong time/throttled I assume.
maybe if I immediately saved all the players data into a table as they leave, then save from the table into the datastore lol? Or maybe clone their DATABAG as they leave, save from it then remove it?
://///////// |
|
|
| Report Abuse |
|
|
|
| 22 Nov 2017 04:42 PM |
I've Had That Problem Too.
The Problem Is The Data Is Stored In The Player, And So As The Player Leaves The Game, The Folder/Value Holding The Data Gets Removed, Causing Some Data To Save as Nil Or Nul, Reseting It To It's Original Value When They Load In Again.
The Solution To This Is Every ~1 Seconds You Save Their Data To A Folder In Replicated Storage, And When They Leave, Save That Data.
I Hope I Could Help You, If You Have Any Further Questions Let Me Know. |
|
|
| Report Abuse |
|
|
|
| 22 Nov 2017 04:47 PM |
| Cant I just clone the bag when they leave, and save from that? Or it will still run a risk of being removed for it can be cloned? |
|
|
| Report Abuse |
|
|
|
| 22 Nov 2017 04:48 PM |
| Values parented to nil can still be referenced so no that isn't the issue. |
|
|
| Report Abuse |
|
|
|
| 22 Nov 2017 04:48 PM |
| If you have 10,000+ people playing, then just shut the game down for a bit and tell them your working on fixing big bugs. |
|
|
| Report Abuse |
|
|
|
| 22 Nov 2017 04:49 PM |
Well timothy, i was doing that but now 128gigabytes says that isnt the problem.
WHAT DO. |
|
|
| Report Abuse |
|
|
|
| 22 Nov 2017 04:50 PM |
Actually, Roblox Using The Destroy() Function To Get Rid Of Players, So The Parent's Arn't Just Set To Nil, Also All The Value Are Reset.
I Have Seen It Happen Too Under Those Circumstances. |
|
|
| Report Abuse |
|
|
RobuxLife
|
  |
| Joined: 19 Sep 2012 |
| Total Posts: 13336 |
|
|
| 22 Nov 2017 04:51 PM |
@REAL
please stop typing like that seriously.
|
|
|
| Report Abuse |
|
|
|
| 22 Nov 2017 04:52 PM |
My Suggestion Would Be To Either:
A.) Make The Values Save To A Folder In Replicated Storage (If It Doesn't Take Changing 25 Scripts)
B.) Save A Copy Of The Data Every ~1 Seconds And Reference To That
C.) In The Script Check The Values You Are Saving Aren't Nil |
|
|
| Report Abuse |
|
|
|
| 22 Nov 2017 04:55 PM |
Or...
D.) Use http://wiki.roblox.com/index.php?title=API:Class/GlobalDataStore/UpdateAsync , UpdateAsync and check if the values you are saving are better then the ones before.
If the values that the game is trying to save are worse than that of the values already saved, return the old values and not the new ones. |
|
|
| Report Abuse |
|
|
|
| 22 Nov 2017 04:59 PM |
"Actually, Roblox Using The Destroy() Function To Get Rid Of Players," 100% wrong. |
|
|
| Report Abuse |
|
|
|
| 22 Nov 2017 05:01 PM |
"Save A Copy Of The Data Every ~1 Seconds And Reference" Thats a fantastic way to meet the save limit and ruin everything. http://wiki.roblox.com/index.php?title=Data_store#Per_Place_Limit |
|
|
| Report Abuse |
|
|
|
| 22 Nov 2017 05:01 PM |
If servers saved everything in a player until that server shut down, itd be full of tens of thousands of useless things which sounds like a hazard.
I think that the data being deleted before it finishes saving sounds like the most reasonable problem. |
|
|
| Report Abuse |
|
|
|
| 22 Nov 2017 05:03 PM |
@128Giga
He means save it to a secure location thats not in the player, not save it to the datastore. This is so when you leave, the game saves the values from the secure location instead of your player. |
|
|
| Report Abuse |
|
|
|
| 22 Nov 2017 05:03 PM |
"If servers saved everything in a player until that server shut down, itd be full of tens of thousands of useless things which sounds like a hazard."
It doesn't do that that would be moronic. It treats the players like everything else in the game is treated when parented to nil, it exist until there are no more references to it and then garbage collection gets rid of it.
When you are saving you still have a reference to it. When you are done saving, assuming you made your script correctly, the reference will be gone and garbage collection will get rid of it. Thats why this works fine. game.Players.PlayerRemoving:connect(function(player) wait(60) print(player.Name) end) |
|
|
| Report Abuse |
|
|
|
| 22 Nov 2017 05:07 PM |
Okay well at the moment, timothys ideas sound the most reasonable because he is the only one who has even proposed something and that he has had the same problem.
I dont care if the scripts are held up by rusty beams, if they work, they work. |
|
|
| Report Abuse |
|
|