helloburp
|
  |
| Joined: 26 Aug 2011 |
| Total Posts: 14376 |
|
|
| 21 Mar 2016 11:58 AM |
Yes, I made a wait function when the game closes, but it seems to not be connected to the game shutting down. I can post my datastore scripts if you guys want, but it works literally 99.999% of the time. I need help.
P.S
I have 2 separate datastores, each part of different scripts. Whenever one is lost the other one is, too. Maybe you can make something of this?
|
|
|
| Report Abuse |
|
|
helloburp
|
  |
| Joined: 26 Aug 2011 |
| Total Posts: 14376 |
|
|
| 21 Mar 2016 12:00 PM |
PPS: The datastore script creates the values before assigning them, so it can't be a loading time issue.
|
|
|
| Report Abuse |
|
|
LTB4
|
  |
| Joined: 05 Mar 2016 |
| Total Posts: 298 |
|
|
| 21 Mar 2016 12:01 PM |
Post it in the original thread, we cant help without code. Your so annoying.
I ᴄᴀɴᴛ ᴅʀᴏᴡɴ ᴍʏ ᴅᴇᴍᴏɴs ᴛʜᴇʏ ᴋɴᴏᴡ ʜᴏᴡ ᴛᴏ sᴡɪᴍ |
|
|
| Report Abuse |
|
|
helloburp
|
  |
| Joined: 26 Aug 2011 |
| Total Posts: 14376 |
|
|
| 21 Mar 2016 12:06 PM |
I didn't want to make a giant textwall for you to scroll through, in fact I did that to make it LESS annoying. I thought this may be a common issue that someone could just link a wiki article to fix. Anyways, here are the two scripts for my Coins datastore.
Enter Script:
local DataStore = game:GetService("DataStoreService"):GetDataStore("Coins")
game.Players.PlayerAdded:connect(function(player) local Coins = Instance.new("IntValue",player) Coins.Name = "Coins" Coins.Value = 300 local key = "player-"..player.userId local SavedCoins = DataStore:GetAsync(key) if SavedCoins then Coins.Value = SavedCoins[1] else DataStore:SetAsync(key,{Coins.Value}) end end)
Leave Script:
local DataStore = game:GetService("DataStoreService"):GetDataStore("Coins")
game.Players.PlayerRemoving:connect(function(player) local key = "player-"..player.userId DataStore:SetAsync(key,{player.Coins.Value}) end)
|
|
|
| Report Abuse |
|
|
helloburp
|
  |
| Joined: 26 Aug 2011 |
| Total Posts: 14376 |
|
| |
|
helloburp
|
  |
| Joined: 26 Aug 2011 |
| Total Posts: 14376 |
|
| |
|
helloburp
|
  |
| Joined: 26 Aug 2011 |
| Total Posts: 14376 |
|
| |
|
helloburp
|
  |
| Joined: 26 Aug 2011 |
| Total Posts: 14376 |
|
| |
|
dave2011
|
  |
| Joined: 02 Oct 2010 |
| Total Posts: 10581 |
|
|
| 21 Mar 2016 10:53 PM |
do you know whether they lose the data on a save or a load?
|
|
|
| Report Abuse |
|
|
mycheeze
|
  |
| Joined: 27 Jun 2011 |
| Total Posts: 6748 |
|
|
| 21 Mar 2016 11:06 PM |
'Yes, I made a wait function when the game closes'
>please explain more |
|
|
| Report Abuse |
|
|
|
| 21 Mar 2016 11:16 PM |
This mabey? http://wiki.roblox.com/index.php?title=API:Class/DataModel/OnClose |
|
|
| Report Abuse |
|
|
helloburp
|
  |
| Joined: 26 Aug 2011 |
| Total Posts: 14376 |
|
|
| 21 Mar 2016 11:50 PM |
I already have this
game.OnClose:connect(function() wait(5) end)
in the game.
|
|
|
| Report Abuse |
|
|
|
| 22 Mar 2016 12:23 AM |
I would not save the coins as players are leaving. If I were you I would save them every time someone gets their coin value changed. This is what im doing in a game I have: I have a game using datastore and thats how I do saves. Every time scripts add EXP they add the EXP using SetAsync and then the scripts use OnUpdate to change the text every time a Level or EXP value gets updated.
-secretidagent |
|
|
| Report Abuse |
|
|
|
| 22 Mar 2016 12:24 AM |
local DataStore = game:GetService("DataStoreService"):GetDataStore("Stats") local connection = DataStore:OnUpdate(script.Parent.Parent.Parent.Parent.userId, function(value) UpdateEXP() --Function that gets new values using GetAsync end)
-secretidagent |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 22 Mar 2016 12:28 AM |
Don't listen to secretidagent.
|
|
|
| Report Abuse |
|
|
|
| 22 Mar 2016 12:30 AM |
@chimmihc It works for me and I am yet to notice any issues with that set up.
-secretidagent |
|
|
| Report Abuse |
|
|
helloburp
|
  |
| Joined: 26 Aug 2011 |
| Total Posts: 14376 |
|
|
| 22 Mar 2016 12:37 AM |
Good idea actually, but what if the coins are massively updating and it reaches it's limit? Hope for the best?
|
|
|
| Report Abuse |
|
|
helloburp
|
  |
| Joined: 26 Aug 2011 |
| Total Posts: 14376 |
|
|
| 22 Mar 2016 12:38 AM |
By limit I mean request limit.
|
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 22 Mar 2016 12:41 AM |
That is the worst possible way you could handle data saving.
|
|
|
| Report Abuse |
|
|
helloburp
|
  |
| Joined: 26 Aug 2011 |
| Total Posts: 14376 |
|
|
| 22 Mar 2016 12:45 AM |
It could be viable in environments where updating isn't that common, but yeah it could break... do you have an idea of how I could do this?
|
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 22 Mar 2016 12:48 AM |
It's not viable anywhere. The request limit is not even the problem, it is a very inefficient way to handle it.
|
|
|
| Report Abuse |
|
|
helloburp
|
  |
| Joined: 26 Aug 2011 |
| Total Posts: 14376 |
|
| |
|
|
| 22 Mar 2016 01:17 AM |
I'm no scripting expert, but I know that scripts generally start at line 1 and work its way down.
Have you considered putting this connect trigger ------------------ game.Players.PlayerRemoving:connect(function(player) local key = "player-"..player.userId DataStore:SetAsync(key,{player.Coins.Value}) end) --------------------------------------
near the top of the script.?
Perhaps having at least above ----------- local DataStore = game:GetService("DataStoreService"):GetDataStore("Coins") ------------------- would help.
May work, May not, but it makes sense to me. |
|
|
| Report Abuse |
|
|
|
| 22 Mar 2016 01:25 AM |
I'd recommend using UpdateAsync instead of SetAsync.
Using SetAsync in multiple servers can cause conflicts.
http://wiki.roblox.com/index.php?title=API:Class/GlobalDataStore/UpdateAsync |
|
|
| Report Abuse |
|
|
helloburp
|
  |
| Joined: 26 Aug 2011 |
| Total Posts: 14376 |
|
|
| 22 Mar 2016 01:33 AM |
What does UpdateAsync do differently than setting it?
|
|
|
| Report Abuse |
|
|