Okay,
Basically I have a script that checks through your backpack to read out all of the tools the player has in output.
If it is working, when the player steps on a brick, it should go in the output and read out the tools something like this:
Tool A, Tool B, Tool C, -- continues going
Currently, my code looks like this and I can't seem to figure out how to convert the table into a string and get it all in one print. I have been successful at getting it out in 3 seperate prints using unpack() but that's not what I wanted to do.
local c = plr.Backpack:GetChildren() local backpack = {} for i = 1,#c do if c[i]:IsA("Tool") then table.insert(backpack, c[i]) end end print() -- output goes here
Thanks, tgarbrecht
It seems like you were attempting to print out the tool instances, but wanted to print out the tool names. This should work:
local c = plr.Backpack:GetChildren() local backpack = {} for i = 1,#c do if c[i]:IsA("Tool") then if i == #c then table.insert(backpack, c[i].Name) else table.insert(backpack, c[i].Name..", ") end end end print(unpack(backpack)) --This will print each of the values in "backpack", each separated by a comma (except for the last value)