generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

What's wrong with this?

Previous Thread :: Next Thread 
ThisUserSecret is not online. ThisUserSecret
Joined: 29 Sep 2012
Total Posts: 1094
07 Dec 2015 06:59 PM
Trying to put all of workspace's objects into a table if they are a part, then print the table.

items = {}

for i, v in pairs(game.Workspace:GetChildren()) do
if v:IsA('Part') then
table.insert(items, v.Name)
print(table.concat(items, ';'))
end
end
Report Abuse
ThisUserSecret is not online. ThisUserSecret
Joined: 29 Sep 2012
Total Posts: 1094
07 Dec 2015 07:04 PM
Bump
Report Abuse
ThisUserSecret is not online. ThisUserSecret
Joined: 29 Sep 2012
Total Posts: 1094
07 Dec 2015 07:36 PM
Bump, anyone?
Report Abuse
wonderful72pike is online. wonderful72pike
Joined: 13 Jul 2010
Total Posts: 7009
07 Dec 2015 07:54 PM
Nothing's wrong, it works fine. Is the script disabled?
Report Abuse
ThisUserSecret is not online. ThisUserSecret
Joined: 29 Sep 2012
Total Posts: 1094
07 Dec 2015 08:04 PM
No it's not... hmm.
Report Abuse
BlueKeyblades is not online. BlueKeyblades
Joined: 11 Oct 2014
Total Posts: 220
07 Dec 2015 11:01 PM
local items = {}
function dig(parent)
for index,part in pairs(part:GetChildren()) do
if part:IsA('Part') then
table.insert(items, v.Name)
elseif part:IsA('Model') then
dig(part)
end
end
print(print(table.concat(items, ';')))
end
dig(game.Workspace)
-- That should get you every part inside the Workspace, even the ones hidden deep within models.

[Work not tested, not bested.]
Report Abuse
hkep is not online. hkep
Joined: 19 Jul 2014
Total Posts: 550
08 Dec 2015 12:30 AM
change "elseif part:IsA('Model') then" to "else"
Report Abuse
hkep is not online. hkep
Joined: 19 Jul 2014
Total Posts: 550
08 Dec 2015 12:32 AM
local items = {}
function dig(parent)
for _,part in pairs(part:GetChildren()) do
if part:IsA('Part') then -- might want to check for WedgeParts etc..
table.insert(items, part) -- v.Name is supposed to be part
else
dig(part);
end
end
print(print(table.concat(items, ';')))
end
dig(game.Workspace)
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
08 Dec 2015 01:13 AM
Search = function(cn,p)
local Childs = {}
local function G(p)
for i = 1,#p do
if p[i]:IsA(cn) then
table.insert(Childs,p[i].Name)
end
G(p[i]:GetChildren()) -- ignoring parts' children is stupid
end
end
G(p:GetChildren())
print(table.concat(Childs,";"))
end

Search("Part",workspace)
Report Abuse
AkaLua is not online. AkaLua
Joined: 27 Jul 2012
Total Posts: 526
08 Dec 2015 01:51 AM
items = {}

for i, v in pairs(game.Workspace:GetChildren()) do
if v:IsA('BasePart') then
table.insert(items, v.Name)
end
end

for i = 1,#items do
print(items[i].Name)
end


-____________________________-
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
08 Dec 2015 02:26 AM
put the table.concat out of the loop.
Report Abuse
DarthStrantax is not online. DarthStrantax
Joined: 31 May 2011
Total Posts: 2610
08 Dec 2015 02:33 AM
dig=function(a,i)if type(a)~='number' then table.foreach(a:children(),function(b)dig(b,i) end) if a:IsA'BasePart' then table.insert(i,a) end end
return i
end
local items=dig(workspace,i)
Report Abuse
BlueKeyblades is not online. BlueKeyblades
Joined: 11 Oct 2014
Total Posts: 220
08 Dec 2015 04:26 PM
local items = {}
function dig(parent)
for index,part in pair(parent:GetChildren()) do
if part:IsA('BasePart') then
table.insert(items, part.Name)
if #part:GetChildren() > 0 then
dig(part)
end
end
end

dig(game)

-- Get every part of the ascendant.

[Work not tested, not bested.]
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image