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: How do I save values?

Previous Thread :: Next Thread 
Soundcrusher is not online. Soundcrusher
Joined: 25 Aug 2011
Total Posts: 559
22 Feb 2013 07:31 AM
How do I save values when someone leaves and load when someone enter the game?
Report Abuse
moryo7 is not online. moryo7
Joined: 19 Jul 2010
Total Posts: 5028
22 Feb 2013 07:35 AM
http://wiki.roblox.com/index.php/Data_persistence
Report Abuse
cart6157 is not online. cart6157
Joined: 28 Feb 2009
Total Posts: 2194
22 Feb 2013 07:40 AM
int = 1
game.Players.PlayerAdded:connect(function(p)
p:WaitForDataReady()
local num = p:LoadNumber("Num")
int = num + 1
end)

game.Players.PlayerLeaving:connect(function(p)
p:WaitForDataReady()
p:SaveNumber("Num",int)
end)

The int adds up everytime a player enters the server.
Report Abuse
Soundcrusher is not online. Soundcrusher
Joined: 25 Aug 2011
Total Posts: 559
22 Feb 2013 07:59 AM
Does this also works at StringValues?
Report Abuse
thedestroyer115 is not online. thedestroyer115
Joined: 19 Dec 2010
Total Posts: 11546
22 Feb 2013 09:47 AM
Did you read the link the first reply gave you?

http://wiki.roblox.com/index.php/Data_persistence
Report Abuse
Soundcrusher is not online. Soundcrusher
Joined: 25 Aug 2011
Total Posts: 559
22 Feb 2013 10:10 AM
Yes I did. And now I'm stuck with a problem me and my friend can't solve.

player:SaveString(player.Clan.Value)

Report Abuse
thedestroyer115 is not online. thedestroyer115
Joined: 19 Dec 2010
Total Posts: 11546
22 Feb 2013 10:34 AM
Tell me what you're trying to do.
Report Abuse
thedestroyer115 is not online. thedestroyer115
Joined: 19 Dec 2010
Total Posts: 11546
22 Feb 2013 10:35 AM
Also, if you did read the wiki page I linked to you'd know that SaveString takes two arguments.
Report Abuse
Soundcrusher is not online. Soundcrusher
Joined: 25 Aug 2011
Total Posts: 559
23 Feb 2013 01:56 AM
I'm trying to save a value of a StringValue who is add onplayerenter. And I'm dutch so I don't understand a lot of english.
Report Abuse
bibo5o is not online. bibo5o
Joined: 17 Jan 2009
Total Posts: 414
23 Feb 2013 03:39 AM
function onPlayerEntered(newPlayer)
newPlayer:WaitForDataReady()
wait(0.5)
newPlayer.leaderstats.Candy.Value = newPlayer:LoadString("Clan")
end

function onPlayerLeave(oldPlayer)
oldPlayer:SaveNumber("Clan", oldPlayer.leaderstats.Clan.Value)
end

game.Players.PlayerAdded:connect(onPlayerEntered)
game.Players.PlayerRemoving:connect(onPlayerLeave)


they should work.
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