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 » Scripting Helpers
Home Search
 

Re: Data Persistence

Previous Thread :: Next Thread 
Tempestatem is not online. Tempestatem
Joined: 12 Nov 2010
Total Posts: 1618
23 Mar 2014 08:36 PM
I have this script, it is not working, can someone troubleshoot?


game.Players.PlayerRemoving:connect(function(player)
player:WaitForDataReady()
player:SaveNumber("Pixels", player.leaderstats.Pixels.Value)
end)

--To save




game.Players.PlayerAdded:connect(function(player)
player:WaitForDataReady()
print(player:LoadNumber("Pixels"))
end)
-- To load
Report Abuse
Tempestatem is not online. Tempestatem
Joined: 12 Nov 2010
Total Posts: 1618
23 Mar 2014 09:10 PM
bump
Report Abuse
jonesj627 is not online. jonesj627
Joined: 06 Oct 2010
Total Posts: 1496
23 Mar 2014 10:13 PM
use datastore, much easier
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
23 Mar 2014 10:14 PM
Something to consider, but I don't see how it can be that much easier.
Report Abuse
jonesj627 is not online. jonesj627
Joined: 06 Oct 2010
Total Posts: 1496
23 Mar 2014 10:15 PM
local DataStore = game:GetService("DataStoreService"):GetDataStore("Points")

game.Players.PlayerAdded:connect(function(player)
local key = "user_" .. player.userId
--we want to give 50 points to users each time they visit
DataStore:UpdateAsync(key, function(oldValue)
local newValue = oldValue or 0 --oldValue might be nil
newValue = newValue + 50
return newValue
end)
end)
Report Abuse
jonesj627 is not online. jonesj627
Joined: 06 Oct 2010
Total Posts: 1496
23 Mar 2014 10:16 PM
you don't even have to save stats when player leaves
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
23 Mar 2014 10:29 PM
True, but it involves an entire function while the other just runs a service. How can that be more efficient?
Report Abuse
Tempestatem is not online. Tempestatem
Joined: 12 Nov 2010
Total Posts: 1618
24 Mar 2014 06:04 AM
Ok.. I just want to know how to fix the script I already have..
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
24 Mar 2014 06:09 AM
Starbound?
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
24 Mar 2014 06:18 AM
How do you guys say it does not work without the MessageOut event or actually playing your game?

You guys never set anything from LoadString/LosdNumber
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
24 Mar 2014 06:20 AM
^
Set >said

*facepalm*
Report Abuse
Tempestatem is not online. Tempestatem
Joined: 12 Nov 2010
Total Posts: 1618
27 Mar 2014 05:46 PM
Bump
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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