Get a table from website

  1. What do you want to achieve? Keep it simple and clear!
    getting multiple variables (a table) from a website.
  2. What is the issue? Include screenshots / videos if possible!
    I’m not sure what function I should use for this
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    a LOT of stuff, tried putting it in a variable, tried NOT doing that, using loadstrings, not using loadstrings
--this is what im doing
loadstring(game:GetService("HttpService"):GetAsync("https://example.com/table"))()
--then using that table and getting a random value from that
print(tablename[math.random(#tablename)])

it’s not working though. throwing “ServerScriptService.Script:2: attempt to get length of a nil value”

1 Like

You probably dont access the table correctly don’t forget to use the decodeJSON function on the table you’re trying to async from the website,
Basically the error says that the table you tried to take from the website is empty or nil

1 Like

i forgot to mention how the table looks on the website-end.
it looks like this

local tablename= {
	29328
    56958
        -- numbers
}

so json decode shouldnt matter

Inside the website it’s coded in lua also?

its raw code, theres nothing in the code of the webpage except for the table. Like pastebin or github raw.

1 Like

Try decode the table and then use it also check if you refer the http service to the right place

2 Likes

this worked, I had to JSONEncode my table, then put that as my website.
so my website looked like this:

[2903892, 230988, 390848]

and my code looked like this:

	local data = httpserv:GetAsync("https://example.com/games")
	local gametable = httpserv:JSONDecode(data)
	print(gametable[math.random(#gametable)])
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.