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 using a better loadstring alternative method, 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-table, raw link or even through a JSON-Encoded-table (which you can also archive with HTTPService:JSONDecode())
The module is uploaded on my current main account’s 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 as a source)
-
HTTP-Service must be enabled if you work with links:
(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:
-
A string-table
-
A raw link
-
A JSON Encoded string-table
-
require(113691930527921).StringTableToTable(stringTableHere)
Examples on how you could use it:
(The table in the pastebin is structured like a normal lua-table format):
{
["SpecialTree"] = {
["Apple"] = 5,
["Banana"] = 3,
["Nuts"] = 4
}
}
Let’s try getting it from a raw link (pastebin) with the module!
local result = require(113691930527921).StringTableToTable("https://pastebin.com/gKa8bR0x")
print(result.SpecialTree.Apple)
Output:
5 ← (Apple from SpecialTree)
Great!
Let’s try that now from another raw link (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 raw link (pastebin) with the module!
local result = require(113691930527921).StringTableToTable("https://pastebin.com/xd4F0feH")
print(result.SpecialTree.Banana)
Output:
3 ← (Banana from SpecialTree)
Keep in mind
-
Links will be automatically converted into /raw links incase they aren’t by my module if supported in the applicableDomains list ONLY if boolTryToFixLink (the second argument) is considered true.
-
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(113691930527921).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 (depending if boolWarnErrorInfo is true), 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.
-
And most importantly, to keep everything orginized and have access to everything at once, basically (All-In-One).
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 Bey’s String Table to Table Converter - Roblox
(Feedbacks are welcome.)
-UPDATES
Lastest update made on 16/10/2024:
-
As of the 10/17/2024 I have inserted 2 giant maps inside the Module as Roblox keeps on denying Appeals on the Asset even though it’s clearly not “Misusing Roblox’s Systems”, which didn’t work out too, but now as of the 10/22/2024 it seems that Roblox may have improved the way they moderate models and the Module is now finally public!
-
Reuploaded the module due to my false account terminations incident and almost rescripted the entire logic, as the module used to be sort of broken & outdated due to the Luau Module that I had overwritten last time, because of how good it currently is and also made a bunch of improvements
-
Added support for a popular raw link domain snippet.host
-
Improved Devforum post (formatting, writing, new title, etc…)
Update (more of a bug fix) made on 01/03/2024:
-
The module works now with every link, not only from applicableDomains
-
Supports now pastes.io where applicableDomains will be converted into proper /raw links 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 module:
-
stringTable → (string-table / Raw link / JSON-Encoded-table).
-
boolTryToFixLink → A boolean for fixing raw links properly through the tryFixingLink function (By default true)
-
boolWarnErrorInfo → A boolean for the warning & error output (By default true)
Have fun using my module and stay safe!
Goodbye!