[uses 3rd party json url] Score system among several experiences

  1. What do you want to achieve?
    I want to achieve the affect where several roblox games can use this one JSON url to create a scoring system
    image

  2. What is the issue?
    I don’t know how to get just one of the values… I’m using the HttpService:GetAsync(url) which gets me the entire json object but I want to grab just one value (example: "Pink":"0")

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

local HttpService = game:GetService("HttpService")
local TeamScoresURL = "THE URL GOES HERE"

print(HttpService:GetAsync(TeamScoresURL))

The following will output

{
  "Pink":"0",
  "NavyBlue":"0",
  "Red":"0",
  "Teal":"0",
  "Lime":"0",
  "Orange":"0",
}


Any help is appreciated on this!

You can use the JSONDecode method of HttpService to parse the JSON string to a Lua dictionary.

local results = --//http request
local data = game:GetService("HttpService"):JSONDecode(results)

print(data.Pink) --//something similar to this, haven't done this before but yee
1 Like

Just saying, you might wanna censor out the tab showing the link above the search bar if you want it private.

1 Like

Thanks for the fast response but what is results variable for like what do I put there?

Thanks for this however I’m not really worried about it.


I’ve never used the roblox http service before sry

Results is just where you call GetAsync to retrieve the JSON output.

As of right now it has the error Can't parse JSON not really sure why. Even when I try to just print data
The current script I have right now is

local HttpService = game:GetService("HttpService")
local TeamScoresURL = "url removed as I don't the devforums link rules"

local results = HttpService:GetAsync(TeamScoresURL)--//http request
local data = HttpService:JSONDecode(results)

print(data)

Print results and verify it’s returning a valid JSON string

Printing results with data var:
Does not work (cant parse json)

Printing results with data var disabled:
Works and prints the json