Help getting data values from a table

I need help getting the values of this table. I’ve followed every tutorial because I couldn’t get it to work the first time but it still doesn’t do anything.

I have tried to change how it prints before and it either returns an error or nil.

I’m trying to get all of the barbershop info. Name, Picture, Desc, Etc then put it on a GUI

local jobs = {
	Barber = {Name = "Barber", Image = "rbxgameasset://Images/BarberImage", Info = "Cutting hair is what we do! Quick start-up, no education needed! Just show up and well give you a job!"},
	GameShop = {Name = "Game Retail", Image = "rbxgameasset://Images/GameRetailImage", Info = "Power to the gamers is our modo! Join us to sell all the games you can think of. Promotion increases pay greatly"},
}

local button = script.Parent
local toggled = false

local jobFrame = script.Parent.Parent.Parent.Parent.JobsBox.JobsFrame

local settingBox = script.Parent.Parent.Parent.Parent.JobsBox
local function onButtonActivated()
	if toggled == false then
		toggled = true
		settingBox.Visible = true
		
		for index = 1, #jobs do
			local itemString = jobs[index]
			print("Index " .. index .. ": " .. itemString)
		end
	
		jobFrame.JobBox.Info.TextFrame.Text = jobs.Barber.Info
		jobFrame.JobBox.Info.TextFrame2.Text = jobs.Barber.Info
		
		jobFrame.JobBox.JobImage.Image = jobs.Barber.Image
		jobFrame.JobBox.Data.JobName.TextLabel.Text = jobs.Barber.Name
		
	else		
		toggled = false
		settingBox.Visible = false
	end
end
 
button.Activated:Connect(onButtonActivated)


It should work. What happens and what do you expect to happen?

If you’re talking about the print for-loop, then there’s an issue there. Right now you’re printing the table index and table’s hexadecimal memory address afterwards. For example, you’re printing the table Barber on the first go, and then GameShop on the second go. To get the elements inside of it, you need to use two for loops:

for i, v in pairs(jobs) do --i will be Barber and GameShop and v will be the tables

    for j, k in pairs(v)

        print("Job " .. i .. " Contents: " .. j .. "--" .. k)
        --Job Barber Contents: Info--Cutting hair is what we do! Quick start-up, no education needed! Just show up and well give you a job!

    end

end
1 Like

You are the absolute greatest! This worked so well, thank you!

Just 1 more question if you can. How would I get only the image label of them both?