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: Data storing?

Previous Thread :: Next Thread 
CaptainGector is not online. CaptainGector
Joined: 02 May 2014
Total Posts: 487
29 Sep 2015 09:52 PM
Helping script a game, what is the best way to do DataStores? I noticed that if I just UpdateSync with a Changed event connected to my NumberValue, it only saves sometimes.

Post your favorite methods and suggestions.
Report Abuse
Blues714 is not online. Blues714
Joined: 23 Dec 2008
Total Posts: 6507
29 Sep 2015 09:58 PM
my way;

game.Players.PlayerAdded:connect(function(Player)
game.ReplicatedStorage.Framework.PlayerData:Clone().Parent = Player
local DataStoreService = game:GetService("DataStoreService")
[datastore] = DataStoreService:GetDataStore("[name of datastore]")

Key = "user_"..Player.userId -- saves by player's id
wait()
[data] = Player.PlayerData[name of data]
[data].Value = [datastore]:GetAsync(Key) or 1

[data].Changed:connect(function(Val) [datastore]:SetAsync(Key, [data].Value) end)
print("Data ready for"..Key)
end)
Report Abuse
Ripepperoni is not online. Ripepperoni
Joined: 04 Jul 2010
Total Posts: 5715
29 Sep 2015 10:00 PM
oh god that is a terrible way
Report Abuse
Blues714 is not online. Blues714
Joined: 23 Dec 2008
Total Posts: 6507
29 Sep 2015 10:00 PM
i didn't want ur opinion qq
Report Abuse
CaptainGector is not online. CaptainGector
Joined: 02 May 2014
Total Posts: 487
29 Sep 2015 10:00 PM
SetAsync will always make sure to save the value?
Report Abuse
Blues714 is not online. Blues714
Joined: 23 Dec 2008
Total Posts: 6507
29 Sep 2015 10:02 PM
it sets a value or overwrites the old value
Report Abuse
CaptainGector is not online. CaptainGector
Joined: 02 May 2014
Total Posts: 487
29 Sep 2015 10:13 PM
Okay, since people (a person) claims that's horrible, anyone else want to share?
Report Abuse
frriend is not online. frriend
Joined: 07 Feb 2010
Total Posts: 577
29 Sep 2015 10:14 PM
SetAsync = Sets the value
GetAsync = Gets the value
Report Abuse
Blues714 is not online. Blues714
Joined: 23 Dec 2008
Total Posts: 6507
29 Sep 2015 10:15 PM
wow ok.
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