So, I have a GUI to show data for different countries, but I am trying to change the script to show data from API for different countries.
local countries = script.Parent
for _,country in pairs(countries:GetChildren()) do
if countries:GetChildren().Class == "ImageButton" then
local Frame = script.Parent
local Time = 10
local com = require(game.ReplicatedStorage.NumberFormat)
function cases()
local HttpService = game:GetService("HttpService")
local request = HttpService:GetAsync("api.com/countries/".. script.Parent.link.Value)
local Stats = HttpService:JSONDecode(request)
local count = Stats.cases
Frame.cases.Text = com.InsertCommas(count)
end
function deaths()
local HttpService = game:GetService("HttpService")
local request = HttpService:GetAsync("api.com/countries/".. script.Parent.link.Value)
local Stats = HttpService:JSONDecode(request)
local count = Stats.deaths
Frame.deaths.Text = com.InsertCommas(count)
end
function recovered()
local HttpService = game:GetService("HttpService")
local request = HttpService:GetAsync("api.com/countries/".. script.Parent.link.Value)
local Stats = HttpService:JSONDecode(request)
local count = Stats.recovered
Frame.recovered.Text = com.InsertCommas(count)
end
function casestoday()
local HttpService = game:GetService("HttpService")
local request = HttpService:GetAsync("api.com/countries/".. script.Parent.link.Value)
local Stats = HttpService:JSONDecode(request)
local count = Stats.todayCases
Frame.casestoday.Text = com.InsertCommas(count)
end
function deathstoday()
local HttpService = game:GetService("HttpService")
local request = HttpService:GetAsync("api.com/countries/".. script.Parent.link.Value)
local Stats = HttpService:JSONDecode(request)
local count = Stats.todayDeaths
Frame.deathstoday.Text = com.InsertCommas(count)
end
while wait(Time) do
cases()
deaths()
recovered()
casestoday()
deathstoday()
end
else
print"oof"
end
end
I am trying to make the .. script.Parent.link.Value
be able to be found in the countries:getall. How would I do this?