Easy way to print tables

so i am making a game were there is a lot of type writing and there is a lot of dialogues
i am new to scripting so I dont know more ways that this

first way: manual typing like write(Table[number string])

second: are for loops but the only problem with them is I cant add a wait so it will write
everything at once

if anyone knows betters and faster ways pls tell me

3 Likes

I use @sleitnick’s TableUtil library which has a custom Print method - docs
This is a great library as it allows for deep printing, custom labels, and cyclic references.

You can download the source for that module here

An example usage:

Requirements for below code to work

This code example assumes that you’ve placed the TableUtil library into a ModuleScript named TableUtil located in ReplicatedStorage.

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local TableUtil = require(ReplicatedStorage.TableUtil)

local myTable = {
	coins = 500,
	gems = 50,
	inventory = {
		weapons = {
			"gun",
			"shiny armor",
		},
	},
}

-- print our table, with the label "my inventory", and deep print (print tables in tables, etc)
TableUtil.Print(myTable, "my inventory", true)

The output is:

my inventory:
 - coins:     [number] 500
 - gems:      [number] 50
 - inventory  [Table]:
 -  - weapons  [Table]:
 -  -  - 1: [string] gun
 -  -  - 2: [string] shiny armor
9 Likes

Depending on what you need to do with the information, ROBLOX’s new “Expressive Output Window” will print fully-navigable tables simply by running print(Table). You can enable this feature in the Beta Features section under File.

1 Like