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: DataStore Saving/Loading.

Previous Thread :: Next Thread 
ZirutoHellfire is not online. ZirutoHellfire
Joined: 16 Aug 2012
Total Posts: 4647
01 Apr 2014 01:14 PM
I am really confused with DataStore and how it saves, what it saves and how it loads, could anyone help me?

But first let me take a selfie
Report Abuse
ZirutoHellfire is not online. ZirutoHellfire
Joined: 16 Aug 2012
Total Posts: 4647
01 Apr 2014 02:23 PM
bump

But first let me take a selfie
Report Abuse
ZirutoHellfire is not online. ZirutoHellfire
Joined: 16 Aug 2012
Total Posts: 4647
01 Apr 2014 03:43 PM
burmp

But first let me take a selfie
Report Abuse
JigglingJack is not online. JigglingJack
Joined: 25 Mar 2014
Total Posts: 11263
01 Apr 2014 03:44 PM
it's basically a long list of a key string and value
which you can use to access data

and it's much more robust than data persistence

i'm asian
Report Abuse
ZirutoHellfire is not online. ZirutoHellfire
Joined: 16 Aug 2012
Total Posts: 4647
01 Apr 2014 03:46 PM
yes but what save? Would you use IntValues/BoolValues? I'm confused by it or is it the key that saves?

But first let me take a selfie
Report Abuse
JigglingJack is not online. JigglingJack
Joined: 25 Mar 2014
Total Posts: 11263
01 Apr 2014 03:48 PM
You get the DataStore from
pts = game:GetService("DataStoreService"):GetDataStore("Points")

the key is generally used for player identifiers
and the value is obviously the value

i'm asian
Report Abuse
ZirutoHellfire is not online. ZirutoHellfire
Joined: 16 Aug 2012
Total Posts: 4647
01 Apr 2014 03:50 PM
Okay here's my code:

level = Instance.new("IntValue")
xp = Instance.new("IntValue")
mana = Instance.new("IntValue")

stats = game:GetService("DataStoreService"):GetDataStore("stats")

function playerConnect(player)
if player:IsA("Player") then
repeat wait() until player.DataReady
level.Parent = player
xp.Parent = player
mana.Parent = player
end
end

game.Players.PlayerAdded:connect(playerConnect)


I just need to know do I save the IntValues to DataStore and how. Or do I create 'values'?
But first let me take a selfie
Report Abuse
JigglingJack is not online. JigglingJack
Joined: 25 Mar 2014
Total Posts: 11263
01 Apr 2014 03:52 PM
stats:SetAsync(key, value)
and use different data stores for different stats

i'm asian
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
01 Apr 2014 03:53 PM
Consider it as a cabinet that has a lot of information in it

local datastore =game:GetService"DataStoreService":GetDataStore("NAMEOFDATASTORE")
^ That tells you which cabinet to look in, and it gives you the cabinet

now

local stuff=datastore:GetAsync("NameOfItem") -- This is like a key to opening the cabinet. Now you got the object you want and you can do whatever you want with it

datastore:SetAsync("NameOfItem", "Potato") --Tis opens up the cabinet, takes out everything inside that section, and replaces it with the second thing, i.e. "Potato" in this case

datastore:UpdateAsync("NameOfItem", function(old) return newvalue end) --This takes out the cabinet info, modifies it according to the function, and replaces it with the modified version

Hope this helped
Report Abuse
ZirutoHellfire is not online. ZirutoHellfire
Joined: 16 Aug 2012
Total Posts: 4647
01 Apr 2014 03:53 PM
So I would not need the IntValues?

But first let me take a selfie
Report Abuse
ZirutoHellfire is not online. ZirutoHellfire
Joined: 16 Aug 2012
Total Posts: 4647
01 Apr 2014 03:54 PM
The current code:

stats = game:GetService("DataStoreService"):GetDataStore("stats")

function playerConnect(player)
if player:IsA("Player") then
repeat wait() until player.DataReady
stats:SetAsync("mana", 0)
end
end

game.Players.PlayerAdded:connect(playerConnect)

is this correct?

But first let me take a selfie
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
01 Apr 2014 03:56 PM
You save the VALUE of the intValue

stats = game:GetService("DataStoreService"):GetDataStore("stats") --This is only a cabinet. You need to open the cabinet with a certain "Key" to get certain information.

function playerConnect(player)
if player:IsA("Player") then
repeat wait() until player.DataReady

local level = Instance.new("IntValue")
local xp = Instance.new("IntValue")
local mana = Instance.new("IntValue")


level.Parent = player
xp.Parent = player
mana.Parent = player
level.Value = stats:GetAsync(player.Name.."Level")
xp.Value = stats:GetAsync(player.Name.."XP")
mana.Value = stats:GetAsync(player.Name.."Mana")--Like this
end
end

game.Players.PlayerAdded:connect(playerConnect)
Report Abuse
ZirutoHellfire is not online. ZirutoHellfire
Joined: 16 Aug 2012
Total Posts: 4647
01 Apr 2014 03:58 PM
Would I not set it then get it? :l

But first let me take a selfie
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
01 Apr 2014 03:59 PM
No, setting would overwrite the current data stored in the DataStore.
Report Abuse
ZirutoHellfire is not online. ZirutoHellfire
Joined: 16 Aug 2012
Total Posts: 4647
01 Apr 2014 04:00 PM
Okay.

But first let me take a selfie
Report Abuse
Duelingwarlord is not online. Duelingwarlord
Joined: 15 Feb 2010
Total Posts: 22333
01 Apr 2014 04:10 PM
http://www.roblox.com/Global-DataStore-item?id=151263580
Report Abuse
ZirutoHellfire is not online. ZirutoHellfire
Joined: 16 Aug 2012
Total Posts: 4647
02 Apr 2014 10:14 AM
I'm now confused with UpdateAsync()

What's "function(old) return newvalue end"

But first let me take a selfie
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
02 Apr 2014 11:48 AM
:UpdateAsync("Potato", function(old) return old+15 end)

This would take the number stored in "Potato", add 15 to it and save it.
Report Abuse
KOzero is not online. KOzero
Joined: 11 May 2010
Total Posts: 1411
02 Apr 2014 11:56 AM
Bump,Going to check this thread later.
Report Abuse
Kingmouli is not online. Kingmouli
Joined: 28 Sep 2012
Total Posts: 1292
02 Apr 2014 11:57 AM
Why is it named old? Like script.Parent.Touched:connect(function(hit) you name it hit because it's the thing that touched it. But old?
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
02 Apr 2014 11:59 AM
The old value that was stored in the DataStore

Report Abuse
ZirutoHellfire is not online. ZirutoHellfire
Joined: 16 Aug 2012
Total Posts: 4647
02 Apr 2014 12:11 PM
@wazap So I'm doing it right?

Shrek is love shrek is life.
Report Abuse
ZirutoHellfire is not online. ZirutoHellfire
Joined: 16 Aug 2012
Total Posts: 4647
02 Apr 2014 12:12 PM
Owait, thought this was another thread hoooldddd on:

-----Saving Code-----
game.Players.PlayerRemoving:connect(function(player)
local level = player.Lvlle
local xp = player.ExpP

stats:UpdateAsync(xp, function(old) return xp.Value end)
stats:UpdateAsync(level, function(old) return xp.Value end) -- Is this right?
end)
-----END-----

Shrek is love shrek is life.
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
02 Apr 2014 12:13 PM
idk what you're doing so I cant say anything.
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
02 Apr 2014 12:14 PM
game.Players.PlayerRemoving:connect(function(player)
local level = player.Lvlle
local xp = player.ExpP

stats:UpdateAsync(xp, function(old) return xp.Value end)
stats:UpdateAsync(level, function(old) return level.Value end) -- Is this right?
end)

Ya that looks right.
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