Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i turn a string value into a table using http?

Asked by 6 years ago

How do i turn this string value into a table, it doesnt work for me :( it basically returns a table in string format and i tred using JSONEncode to make it into code? idk help me please!

local Message = game:GetService("HttpService"):GetAsync("http://pastebin.com/raw/R6wy0FNx", true)


while wait(1) do
    Message = game:GetService("HttpService"):GetAsync("http://pastebin.com/raw/R6wy0FNx", true)
    print(game.HttpService:JSONEncode(Message[1]))

end



1 answer

Log in to vote
0
Answered by
Azarth 3141 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

Your message returns a full string that needs to be parsed, not a JSON table. Each string of numbers needs to be separated and inserted into a table that you can then access.

local http_service = game:GetService("HttpService")

local Message = http_service:GetAsync("http://pastebin.com/raw/R6wy0FNx", true)

local ids = {}
-- Matches each string of numbers and inserts them into a table
for i in string.gmatch(Message, "%d+") do 
    table.insert(ids, i)
end

print(ids[1])

0
OMG THANK YOU I WAS THINKING OF STRING MANIPULATION ahhhh thx UltraUnitMode 419 — 6y
Ad

Answer this question