How do I print whats inside of a table

–// Lets label our tables first
–// Table 1 - The Primary Table | Dealers
–// Table 2 - Inside the primary table | Vehicles

  1. What do you want to achieve? I’m trying to make a somewhat close fully automated car spawn system for adding new dealers then adding all those vehicles inside of it

  2. What is the issue? I can get it to print the dealers but not the vehicles as it would print nil.

  3. What solutions have you tried so far? I tried doing a few real time help in Hidden Developers and a few other disc but they usually ended up ignoring me.
    But for solutions for the Dealer printing I would do a for i do through the entire module script

Module Script

local VehiclesSpawners = {}

VehiclesSpawners.Spawner1 = { -- It prints these
	Vehicle1 = { -- But not whats in here which I dunno what to do ;(
		ClickDetector = game.Workspace, -- Location of interaction
		VehicleLocation = game.ServerStorage, -- Vehicle Storage location
		Vehicle_Name = "", -- Vehicle Name
		Vehicle_Description = "", -- Description of vehicle
		Vehicle_Price = 0 -- Not needed for now as vehicles wont have a price
	},
	
	Vehicle2 = {
		ClickDetector = game.Workspace, -- Location of interaction
		VehicleLocation = game.ServerStorage, -- Vehicle Storage location
		Vehicle_Name = "", -- Vehicle Name
		Vehicle_Description = "", -- Description of vehicle
		Vehicle_Price = 0 -- Not needed for now as vehicles wont have a price
	},
	
	Vehicle3 = {
		ClickDetector = game.Workspace, -- Location of interaction
		VehicleLocation = game.ServerStorage, -- Vehicle Storage location
		Vehicle_Name = "", -- Vehicle Name
		Vehicle_Description = "", -- Description of vehicle
		Vehicle_Price = 0 -- Not needed for now as vehicles wont have a price
	}
}

VehiclesSpawners.Spawner2 = {
	Vehicle1 = {
		ClickDetector = game.Workspace, -- Location of interaction
		VehicleLocation = game.ServerStorage, -- Vehicle Storage location
		Vehicle_Name = "", -- Vehicle Name
		Vehicle_Description = "", -- Description of vehicle
		Vehicle_Price = 0 -- Not needed for now as vehicles wont have a price
	},
	
	Vehicle2 = {
		ClickDetector = game.Workspace, -- Location of interaction
		VehicleLocation = game.ServerStorage, -- Vehicle Storage location
		Vehicle_Name = "", -- Vehicle Name
		Vehicle_Description = "", -- Description of vehicle
		Vehicle_Price = 0 -- Not needed for now as vehicles wont have a price
	},
	
	Vehicle3 = {
		ClickDetector = game.Workspace, -- Location of interaction
		VehicleLocation = game.ServerStorage, -- Vehicle Storage location
		Vehicle_Name = "", -- Vehicle Name
		Vehicle_Description = "", -- Description of vehicle
		Vehicle_Price = 0 -- Not needed for now as vehicles wont have a price
	}
}


return VehiclesSpawners

Printing Script

local Script = script.Parent.ModuleScript
local Require = require(Script)

for i, PrintRequires in pairs(Require) do
-- Create Car Dealer
	local MainFolder = Instance.new("Folder", game.Workspace)
	MainFolder.Name = i
end```

You can do something along the lines of this:

for i, PrintRequires in pairs(Require.Spawner1) do --Spawner1 is the name of your table in the module
    -- code here
end

So spawner1 Is the name of one of the “Testing” Dealers I’ve made it create a folder of each “Dealer” In the script and currently that part work. My next achievement which is what I made this post for is trying to figure out how to automatically list all the vehicles inside of the Dealers!

image|188x89

You can just keep iteration until you get to the end:

for _, Table in pairs(Require) do
    for _, Item in pairs(Table) do
        print(Item) -- Prints the item in the second table
    end
end
1 Like

Heyy, Thanks I got it. When I first did it for some reason It was printing nil which was odd but It works now Screenshot by Lightshot

If you’re trying to print a table only for debugging purposes, I recommend you activate the Expressive Output Window beta.
Hence, a single print(MyTable) will show the entire table.