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: How many of you guys script?

Previous Thread :: Next Thread 
Synthical is not online. Synthical
Joined: 06 Apr 2014
Total Posts: 2075
27 Nov 2014 09:19 PM
Scripters are no help, so I m coming here. So, I am trying to use data persistence, and it didn't work, here's the script:
game.Players.PlayerAdded:connect(function(player)
local leaderstats = Instance.new("Model", player)
leaderstats.Name = "leaderstats"
local Interest = Instance.new("IntValue", leaderstats)
Interest.Name = "Bank"
Interest.Value = 0
end)

while wait(2.5) do
for _,Player in pairs(game.Players:GetPlayers()) do
if Player:FindFirstChild("leaderstats") then
Player.leaderstats.Bank.Value = Player.leaderstats.Bank.Value +25
end
end
end
game.Players.PlayerRemoving:connect(function(player)
if player:FindFirstChild("leaderstats") then
player:SaveNumber(player.leaderstats.Score.Value)
end
end)
Report Abuse
slerps is not online. slerps
Joined: 15 Nov 2013
Total Posts: 5174
27 Nov 2014 09:20 PM
lua is hard for me
Report Abuse
Synthical is not online. Synthical
Joined: 06 Apr 2014
Total Posts: 2075
27 Nov 2014 09:20 PM
Data Persistence confuses me.
Report Abuse
Synthical is not online. Synthical
Joined: 06 Apr 2014
Total Posts: 2075
27 Nov 2014 09:21 PM
I went to the wiki as well, and I couldn't figure it out.
Report Abuse
slerps is not online. slerps
Joined: 15 Nov 2013
Total Posts: 5174
27 Nov 2014 09:21 PM
http://wiki.roblox.com/index.php?title=Data_persistence
Report Abuse
slerps is not online. slerps
Joined: 15 Nov 2013
Total Posts: 5174
27 Nov 2014 09:22 PM
nvm then lol
Report Abuse
hulkkid45 is not online. hulkkid45
Joined: 16 Aug 2013
Total Posts: 4724
27 Nov 2014 09:22 PM
I don't know what to tell you.



Come here child, I will tickle you ༼ຈل͜ຈ༽
Report Abuse
SmilingGuyMeme is not online. SmilingGuyMeme
Joined: 05 Apr 2011
Total Posts: 1062
27 Nov 2014 09:22 PM
im just learning basic math
Report Abuse
Cindering is not online. Cindering
Joined: 28 Feb 2009
Total Posts: 8171
27 Nov 2014 09:23 PM
Data persistence is obsolete. Look up Data Stores instead, they are more reliable and easier to use.
Report Abuse
Synthical is not online. Synthical
Joined: 06 Apr 2014
Total Posts: 2075
27 Nov 2014 09:23 PM
I went on that wiki as well, it doesn't make sense to me, if there was a full script of it, then I would maybe understand how it works.
Report Abuse
Synthical is not online. Synthical
Joined: 06 Apr 2014
Total Posts: 2075
27 Nov 2014 09:23 PM
Thanks Cindering, I'll try that.
Report Abuse
Powerhalo is not online. Powerhalo
Joined: 16 Jun 2010
Total Posts: 1504
27 Nov 2014 09:24 PM
Yep, don't use free models, they often use the outdated data persistence, data store allows much more freedom than data persistence.
Report Abuse
Synthical is not online. Synthical
Joined: 06 Apr 2014
Total Posts: 2075
27 Nov 2014 09:25 PM
Power, I scripted this my self.
Report Abuse
Synthical is not online. Synthical
Joined: 06 Apr 2014
Total Posts: 2075
27 Nov 2014 09:34 PM
Cindering, that looks more complicated. How would I tie my script into it?
Report Abuse
Cindering is not online. Cindering
Joined: 28 Feb 2009
Total Posts: 8171
27 Nov 2014 10:50 PM
Data Stores give you pretty much unlimited storage to the server. You'd start by calling the service:

DataStoreService = game:GetService("DataStoreService")

then when a player joins, you can load their data:

local playerdata = DataStoreService:GetDataStore(player.userId.."_data")

You can hold all of the player's stats in this data store. Each value is saved as a "key" which you can refer back to later. If you wanted to load a player's "Bank" stat, you'd do:

local bank = playerdata:GetAsync("Bank") --loads the stat
if bank == nil then --it will be nil the first time you load it
bank = 0
end

and then assign that loaded value to the leaderstat that you will create.
Data stores allow you to load and save values at any time, so you could add this to your loop to continuously save the value:

playerdata:IncrementAsync("Bank",25) --just keep in mind that there is a limit to data store requests per minute
Report Abuse
kilerAK24 is not online. kilerAK24
Joined: 01 Feb 2012
Total Posts: 14
27 Nov 2014 11:13 PM
Not to sound like a newbie, but I would like to know what Async means.
Report Abuse
Synthical is not online. Synthical
Joined: 06 Apr 2014
Total Posts: 2075
27 Nov 2014 11:14 PM
@Cindering, what I want to know is, how do I put it into my script to save every time its value does up by 25? That is all I am wondering.
Report Abuse
Synthical is not online. Synthical
Joined: 06 Apr 2014
Total Posts: 2075
27 Nov 2014 11:17 PM
"Unknown Global player" Wtf?
Report Abuse
Synthical is not online. Synthical
Joined: 06 Apr 2014
Total Posts: 2075
27 Nov 2014 11:22 PM
I don't even get where to insert anything anymore, I am so lost right now.
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
28 Nov 2014 01:39 AM
Async means Asynchronous
It means that everything else carries on without it.
Report Abuse
Powerhalo is not online. Powerhalo
Joined: 16 Jun 2010
Total Posts: 1504
28 Nov 2014 05:47 PM
Synthical, it'll save the values when the player leaves, I don't see any reason to save it each 25 money. It'll slow the server for nothing.
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