[No Use Anymore] Printing Tables

Roblox changed printing tables some time ago, so when you tried to print a table, it would randomly print items like table: 0x09e053889b230d20 and table: 0x7753d8af650573b0.

Also, unpack doesn’t work for non-numerical tables.

I’ve made a function so that you can print tables in the old format:

function PrintTable(tbl,key,queue)
	-- tbl is a table or value in a table
	-- key is the number or position in the table
	-- queue is how far a value is in a table
	local function FormatBetween(formatBetween,stringTable)
		local strToReturn
		for k,n in pairs(stringTable) do
			strToReturn = (strToReturn or "") .. (k == 1 and "" or formatBetween) .. n
		end
		return strToReturn
	end
	
	queue = queue or 1
	if type(tbl) == "table" then
		for k,n in pairs(tbl) do
			PrintTable(n,k,queue + 1)
		end
	else
		local addOn
		local formatTable = {}
		for i = 1,queue - 1 do
			table.insert(formatTable,"	")
		end
		if queue > 1 then
			table.insert(formatTable,"►")
		end
		addOn = FormatBetween(" ",formatTable) or ""
		if key then print(addOn,'["' .. key .. '"] =',tbl) else print(addOn,tbl) end
	end
end

(You can edit the source code however you want!)

Try using it with PrintTable(game.MarketplaceService:GetProductInfo(game.PlaceId)) to see the results!

Or you can require the module with PrintTable = require(6870361592) or inserting it with https://www.roblox.com/library/6870361592/PrintTable.

Example:
require(6870361592)(game.MarketplaceService:GetProductInfo(606849621))
-- this is JailBreak's game id, by the way

prints:

4 Likes

This happens because “Log Mode” is enabled in the output settings, turning it off fixes the problem:

12 Likes