generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: People in my game are losing datastore data, any ideas?

Previous Thread :: Next Thread 
helloburp is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. helloburp
Joined: 26 Aug 2011
Total Posts: 14376
21 Mar 2016 01:24 PM
b


Report Abuse
helloburp is not online. helloburp
Joined: 26 Aug 2011
Total Posts: 14376
21 Mar 2016 04:55 PM
b2


Report Abuse
helloburp is not online. helloburp
Joined: 26 Aug 2011
Total Posts: 14376
21 Mar 2016 08:11 PM
b3
Report Abuse
helloburp is not online. helloburp
Joined: 26 Aug 2011
Total Posts: 14376
21 Mar 2016 10:50 PM
b4


Report Abuse
dave2011 is not online. 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 is not online. 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
LuaDeveloped is not online. LuaDeveloped
Joined: 28 Jan 2016
Total Posts: 439
21 Mar 2016 11:16 PM
This mabey?
http://wiki.roblox.com/index.php?title=API:Class/DataModel/OnClose
Report Abuse
helloburp is not online. 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
secretidagent is online. secretidagent
Joined: 07 Nov 2010
Total Posts: 1600
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
secretidagent is online. secretidagent
Joined: 07 Nov 2010
Total Posts: 1600
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 is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
22 Mar 2016 12:28 AM
Don't listen to secretidagent.


Report Abuse
secretidagent is online. secretidagent
Joined: 07 Nov 2010
Total Posts: 1600
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 is not online. 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 is not online. helloburp
Joined: 26 Aug 2011
Total Posts: 14376
22 Mar 2016 12:38 AM
By limit I mean request limit.


Report Abuse
chimmihc is not online. 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 is not online. 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 is not online. 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 is not online. helloburp
Joined: 26 Aug 2011
Total Posts: 14376
22 Mar 2016 12:50 AM
You have any solutions?


Report Abuse
ShiningLuck is not online. ShiningLuck
Joined: 05 Jun 2008
Total Posts: 468
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
Twenty9Nine is not online. Twenty9Nine
Joined: 03 Aug 2015
Total Posts: 137
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 is not online. helloburp
Joined: 26 Aug 2011
Total Posts: 14376
22 Mar 2016 01:33 AM
What does UpdateAsync do differently than setting it?


Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image