Change Text on TextButton using HttpService

Hello. I’ve never used the HttpService before, and I need help with this script. What I want to do is change the text on a TextButton (or TextLabel) by using HttpService, I have the website ******/randombadge and I would like to display something that is on there. How would I do that? This is my script. (I got it from HttpService)

local HttpService = game:GetService("HttpService")
 
local URL_ASTROS = "this.is.an.example.com"
local response = HttpService:GetAsync(URL_ASTROS)
local data = HttpService:JSONDecode(response)

if data.message == "success" then
	script.Parent.Text = data.description
	end
script.Parent.Text = data.message

that’s all, pretty easy right?

I’m getting no errors, and It’s not working still.

Print data, what does it output?

Can you please show me the json? or perhaps print the data and tell me the output

is it a table or just a simple plain word/sentence?

It’s a table.

I’ll do that now.

1 Like

Any luck?

Nothing, still. It’s a replit (hosting website) and maybe that could be the reason why it isn’t working? It has been showing an error page for hours.

i’m not sure how to get the json out of a repl.it, i’ve never tried it before. perhaps use a pastebin page or github page

Edit: @Lostude thanks for the like :heart:

2 Likes

Okay, thanks! I’ll try that now.

1 Like

Dont forget to update me A.S.A.P once you’re done!

1 Like