What is wrong with this? I'm trying to get a table from Here
local Http = game:GetService("HttpService") local Data = Http:GetAsync("http://pastebin.com/raw.php?i=ci5YECCB",true) if Data.Cake == false then print"Nope" end
Essentially, that HTTP GET request returns, explicitly:
Data = [[{ ["Cake"] = false, ["Pie"] = true, }]]
On its own, this is just a string, not a table like you expect. There are two methods to get around this.
The first, loadstring
, is not available in LocalScripts, and many features become disabled if you enable loadstring
in Scripts, but is by far the simpler:
loadstring(Data)() -- The first parentheses create the function that contains the string interpreted as Lua code. the second call that function.
The second, which also is not available in LocalScripts for obvious reasons, is to fomat the text you want to load using JSON, and use HTTPService:JSONDecode to convert it to a Lua table. Technically, this will only work using Tables, and I haven't tested but I don't believe you can store functions even as members of Tables using this method.