How do i print out all the contents of a table?

here is an in-depth description of it:
Cart is my table that is full of nothing but object values.
Im trying to print out each of the object value’s object names.

so for example
ObjectVal1.Value = “Model1”
ObjectVal2.Value = “Model2”

what i want is to print out objectval 1 and 2’s values name.
So i want this to show up in the console:
Model1
Model2

NOT
Model1 Model2

Btw, this is for a shop. thats why my table is called “cart”. its like a cart in online shops so you cna buy bulks of items.

Thanks if you understand!

for _,v in pairs(Table)
     print(v.Value.Name)
end
1 Like

you can use a for loop to print out the contents of a table like so,

local myTable = {
	John = 22,
	Mary = 43,
	Steven = 26
}
for i,v in myTable do
	print(i .. " = " .. v)
end

output:

John = 22
Mary = 43
Steven = 26

nothing working… im kinda curious (because its getting cart from an event) if cart isint even a table… liek if im not sending the table right… lemem check

1 Like

just checked, the sending script sends a table… the reciving script GETS a EMPTY table???/
i checked, the table being sent has stuff in it… so idk why its empty on the other side

If your sending the table from a localScript to a serverScript make sure in the recieving end to get (_, yourtable) because when you fire a remote event from a local script it will always pass through the player aswell.

i just told you, the sending script sends a full table, the reciving script does not.
Its local to client yes

sending:

Event:FireServer(Cart, tonumber(Price.Text))

Reciving:

Event.OnServerEvent:Connect(function(plr, Cart, Price)

print the table in the local script before passing it through in the fireserver, tell me what it outputs

bruhhhh i already told you, the LOCAL side prints the table
the SERVER side prints “{}”, so an empty table

what is the table consisting of? If you send a table of instances (INCLUDING ObjectValues) these NEED to exist on the Server as well, or they will be nil on the server.

2 Likes

i was somehow able to make changed so now the values get made serverside… idk HOW i did it with no errors but im happy

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.