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
|
  |
| Joined: 18 Apr 2012 |
| Total Posts: 3893 |
|
| |
|
YumERAGON
|
  |
| Joined: 18 Apr 2012 |
| Total Posts: 3893 |
|
| |
|
|
| 04 Jun 2016 05:23 PM |
| How did you save them? (Show us the table you encoded/saved) |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 18 Apr 2012 |
| Total Posts: 3893 |
|
|
| 04 Jun 2016 05:41 PM |
^ doesn't work
output --> Can't parse JSON |
|
|
| Report Abuse |
|
|
|
| 04 Jun 2016 05:41 PM |
table.Value = table.Value + 1
r+://393244197r+://393244224r+://393244262 |
|
|
| Report Abuse |
|
|
YumERAGON
|
  |
| Joined: 18 Apr 2012 |
| Total Posts: 3893 |
|
| |
|
YumERAGON
|
  |
| Joined: 18 Apr 2012 |
| Total Posts: 3893 |
|
| |
|
YumERAGON
|
  |
| Joined: 18 Apr 2012 |
| Total Posts: 3893 |
|
| |
|