You can write your topic however you want, but you need to answer these questions:
Q: What do you want to achieve? Keep it simple and clear! A: I want to print the table like a string including it’s content.
Q: What is the issue? Include screenshots / videos if possible! A: I don’t know how much time passed but I clearly remember that I would print the table and its content just using the snippet below.
But today it seems like that I can’t print the table like this. Also it prints some hexadecimal like this 0x9044f509085b95a6 instead of the content of the table and ChatGPT also approved me at it is
hexadecimal.
Q: What solutions have you tried so far? Did you look for solutions on the Developer Hub? A: I tried using tostring() but it did not solve my problem and similar questions was absolutely not similar.
Please describe if you know a solution for this!
I think I would not reply for 2 hours because I have got some tasks out.
function Inspect(Object, Indent)
local INDENT = " "
Indent = Indent or 0
if type(Object) == "table" then
local Inspection = "{"
for i, v in pairs(Object) do
if Inspection ~= "{" then
Inspection = Inspection..","
end
Inspection = Inspection.."\n".. string.rep(INDENT, Indent) .. "["..Inspect(i, Indent + 1).."] = "..Inspect(v, Indent + 1)
end
return Inspection.."\n"..(string.rep(INDENT, Indent - 1)).."}"
elseif type(Object) == "string" then
return '"'..Object..'"'
else
return Object
end
end
function print_t(Table)
print(Inspect(Table, 1))
end
local RandomTable = {["TableContent1"] = "Hello ", [2] = "World!", [3] = {"Nested", "table"}}
print_t(RandomTable)
Problem: Roblox Studio crashed instantly. Solution: I tried removing RunService.HeartBeat and used while loop instead because recently it was printing too much errors and I thought that caused the crash.
Problem: Roblox Studio isn’t crashing but also not responsing inputs. I also see a Exhausted allowed execution time error. Hardly ever stopped the game. Solution: I tried increasing loops task.wait()
I think I will create a module script for printing tables and iterate through table using a loop.
Sorry guys I solved it now. Actually I am using Terrain:ReadVoxels() and the terrain is pretty huge in 3D space (1024, 128, 1024) so it prints lots of tables inside and inside all they contain materials. Also that is the reason why script exhausted allowed execution time.