Greetings and welcome to this small tutorial!
If you’ve encountered difficulties extracting a Roblox lua-table from a string, then you’re in the right place as I have developed a module specifically designed to getting that actual Roblox lua-table from a string, so that other people don’t have to go through the pain.
This converter is designed to get the actual lua-table from a string / pastebin / pastebinlink or even through a JSON-Encoded-table (which you can also archive with HTTPService:JSONDecode())
The module is uploaded on my profile and has been made open-source (published incase of updates), meaning that you can simply require it by using the following require method (below):
Requirements:
- The module (Obviously)
- HTTP-Service must be enabled:
(to be able to access third-party-requested links and use them inside the module)
How to use it:
-
First you have to require the module and use the module.StringTableToTable function, then you put in the “stringTableHere” either one of these following things:
-
The string-table
-
Pastebin string-table / Pastebinlink
-
JSON Encoded string-table
-
require(15301898379).StringTableToTable(stringTableHere)
Examples on how you could use it:
(The table in the pastebin is structured like a normal table format):
{
["SpecialTree"] = {
["Apple"] = 5,
["Banana"] = 3,
["Nuts"] = 4
}
}
Let’s try getting it from the pastebin with the module!
local result = require(15301898379).StringTableToTable("https://pastebin.com/gKa8bR0x")
print(result.SpecialTree.Apple)
Output:
5 ← (Apple from SpecialTree)
Great!
Let’s try that now from another pastebin that is this time structured into the Encoded JSON format:
(The table in the pastebin is this time structured in an Encoded JSON table format):
{"SpecialTree":{"Apple":5,"Banana":3,"Nuts":4}}
Let’s try getting it from the pastebin with the module!
local result = require(15301898379).StringTableToTable("https://pastebin.com/xd4F0feH")
print(result.SpecialTree.Banana)
Output:
3 ← (Banana from SpecialTree)
Keep in mind
- Pastebin links will be automatically converted into raw links incase they aren’t by my module.
- Using HTTPService:GetAsync() is willing to return the information as a string, which when you have a table inside that information we then consider as a string-table. That’s why I made this module so we don’t have to deal with that problem and we can easily get the actual lua-table back with the help of my module!
(So it will be “readable” for lua)
Now let’s try something different instead of using pastebin…
local StringTable = [[{
["Name"] = "John",
["Job"] = "Police Officer",
["Level"] = 32
}]]
local result = require(15301898379).StringTableToTable(StringTable)
local Name = result.Name
local Job = result.Job
local Level = result.Level
print("Name: "..Name.." / ".."Job: "..Job.." / ".."Level: "..Level)
Output:
Name: John / Job: Police Officer / Level: 32
And that’s it!
The module will then (if used correctly) return the string table to an actual Roblox lua-table that you can use further. If the string table contains an invalid format then it warns the error out, and usually returns the table to nil to prevent script errors.
Why did I make this module?
-
Because I’ve seen a lot of people that have been using Roblox’s .LoadStringEnabled method which is a working one BUT extremly unsafe method at the same time, as it simply makes exploiters vulnerable to use loadstring() to take control of the game if used uncorrectly.
-
I also made this module because I know that a lot of people love to use the normal lua-table format, as it may be simpler to-use, are used to work with them, and may be better readable than a JSON table.
For what would this be useful?
- This would be extremly useful for making list-themed scripts (like a ban list e.g) via third party sites such as: (Pastebins for example)
Thank you for making it this far of this tutorial, I hope you enjoyed this short tutorial on how to use TraderBey’s String Table to Table Converter - Roblox
(Feedbacks are welcome.)
-UPDATES
Last update (more of a bug fix) made on 01/03/2024:
-
The module works now with every link and not only pastebin.com
-
Supports now pastes.io where applicableDomains will be converted into /raw if not included (pastebin alternative since I noticed that pastebin goes rarely down and is not available in certain countries)
Current and possible arguments for the script are now:
- StringTable / Link. (Same)
- A boolean for the warning output (New, is automatically true if not included)
Have fun using my module and stay safe!
Goodbye!