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 can i access children of a saved table

Previous Thread :: Next Thread 
YumERAGON is not online. YumERAGON
Joined: 18 Apr 2012
Total Posts: 3893
04 Jun 2016 04:51 PM
DataStore:GetAsync(Player.UserId, HttpService:JSONDecode(SavedValues)
This contains 2 values --> StringValue and NumberValue
How can I print them both separately(E.G["String"][1]) rather than ["String", 1]
Report Abuse
YumERAGON is not online. YumERAGON
Joined: 18 Apr 2012
Total Posts: 3893
04 Jun 2016 05:13 PM
b
Report Abuse
YumERAGON is not online. YumERAGON
Joined: 18 Apr 2012
Total Posts: 3893
04 Jun 2016 05:23 PM
b2
Report Abuse
Void_Optics is not online. Void_Optics
Joined: 21 Mar 2016
Total Posts: 286
04 Jun 2016 05:23 PM
How did you save them? (Show us the table you encoded/saved)
Report Abuse
GGGGG14 is not online. GGGGG14
Joined: 29 Jan 2012
Total Posts: 25344
04 Jun 2016 05:28 PM
When saving dictionary/map-style tables w/ string keys... roblox randomizes their order...

just do tab["str"][1]
Report Abuse
YumERAGON is not online. YumERAGON
Joined: 18 Apr 2012
Total Posts: 3893
04 Jun 2016 05:30 PM
Full script =

local SavedValues = {}
local DataStore = game:GetService("DataStoreService"):GetDataStore("DataStoreSave")
local HttpService = game:GetService("HttpService")
local DeBounce = false
local ReturnedValues = {}

game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Character)
_G.Player = Player
_G.Character = Character
DataStore:GetAsync(Player.UserId, HttpService:JSONDecode(SavedValues))
print(DataStore:GetAsync(Player.UserId, HttpService:JSONDecode(SavedValues)))
--trying to access the values of SavedValues individually
end)
end)

workspace.Part.Touched:connect(function(hit)
if hit.Parent.Name == _G.Character.Name and DeBounce == false then
DeBounce = true
for i,v in pairs(_G.Player.PlayerGui:GetChildren()) do
if v.ClassName == "StringValue" or v.ClassName == "NumberValue" then
table.insert(SavedValues, v.Value)
end
end
DataStore:SetAsync(_G.Player.UserId, HttpService:JSONEncode(SavedValues))
print(DataStore:GetAsync(_G.Player.UserId, HttpService:JSONDecode(SavedValues)))
end
end)
Report Abuse
GGGGG14 is not online. GGGGG14
Joined: 29 Jan 2012
Total Posts: 25344
04 Jun 2016 05:37 PM
Here...

local HttpService = game:GetService("HttpService")
local aJSON = [=[["a"=1; "b"=2; "c"=3]]=]

local JSON_table = HttpService:JSONDecode(aJSON)

print(tostring(JSON_table["b"]))
Report Abuse
YumERAGON is not online. YumERAGON
Joined: 18 Apr 2012
Total Posts: 3893
04 Jun 2016 05:41 PM
^ doesn't work

output --> Can't parse JSON
Report Abuse
iJacobness is not online. iJacobness
Joined: 20 Jan 2014
Total Posts: 4944
04 Jun 2016 05:41 PM
table.Value = table.Value + 1


r+://393244197r+://393244224r+://393244262
Report Abuse
YumERAGON is not online. YumERAGON
Joined: 18 Apr 2012
Total Posts: 3893
04 Jun 2016 05:55 PM
b
Report Abuse
YumERAGON is not online. YumERAGON
Joined: 18 Apr 2012
Total Posts: 3893
04 Jun 2016 06:06 PM
b
Report Abuse
YumERAGON is not online. YumERAGON
Joined: 18 Apr 2012
Total Posts: 3893
04 Jun 2016 06:55 PM
b
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