Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

why is this table.insert script printing out some weird codes?

for i,v in pairs(game.Workspace.abc:GetChildren()) do	
	local tab,val = {},v.Name
	table.insert(tab, val)
	print(tab,val)
end

Basically this script is supposed to print "test" since the parts in abc model are t, e, s, t but instead i get this: table: 0x0ba418710f62d17d t table: 0xfb33a005be1626bd e table: 0x6f05649465964e3d s table: 0x1b34c652dafdfa5d t

im a scripting beginner so maybe thats just a feature that i dont know about. any help would be appreciated.

2 comments

0

Currently, you're printing out the table value. Not the value inside the table.

0

ooh k thanks

2 answers

✓ Accepted answer

You are trying to print the table, not the value in the table. Also another thing i would like to point out is you are trying to do table.insert(table, value) when the second parameter should really be the position where the value is gonna be inserted. So in your case you should do table.insert(tab, 1, value). And to print out the value and not the table use print(tab[1])

2 comments

0

The position parameter is optional. If only two paramters are passed, the second parameter is assumed to be the value.

0

Ooh didint know that

I'm not 100% sure what you're trying to do, but I created this script that lists all the objects in Workspace and puts them inside the table.

for _,part in pairs(game.Workspace:GetChildren()) do
	local tab,val = {},part.Name
	table.insert(tab,val)
	print(tab[1])
end

To index the value of a table you have to do this.

print(TABLE_NAME[WHICH VALUE YOU WANT INDEXED])

And that will print the number 1 spot in the table name.

If you need more explanation, let me know. I'm willing to help a fellow scripter out.

This discussion is preserved as it was. New answers, comments, and votes are closed.