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 » Scripting Helpers
Home Search
 

Re: How do you combine multiple getChildren scripts?

Previous Thread :: Next Thread 
SuperSoldier44 is not online. SuperSoldier44
Joined: 13 Jun 2012
Total Posts: 37
25 Jun 2012 02:11 PM
For example

a = game.Workspace.SuperSoldier44.Chest:getChildren()
for i = 1, #a do
if a[i].className == "Part" then
a[i].Transparency = 0.6
end
end

and

b = game.Workspace.SuperSoldier44.Arm1:getChildren()
for i = 1, #b do
if b[i].className == "Part" then
b[i].Transparency = 0.6
end
end
Report Abuse
noobertuber is not online. noobertuber
Joined: 16 Jan 2007
Total Posts: 2321
25 Jun 2012 02:14 PM
a = game.Workspace.SuperSoldier44.Chest:getChildren()
b = game.Workspace.SuperSoldier44.Arm1:getChildren()
for i = 1, #b do
a[#a+1] = b[i]
end

for i = 1, #a do
if a[i].className == "Part" then
a[i].Transparency = 0.6
end
end

There may be a table function for this, but I don't have it memorized.

-God Bless-
Report Abuse
SuperSoldier44 is not online. SuperSoldier44
Joined: 13 Jun 2012
Total Posts: 37
25 Jun 2012 02:19 PM
If I wanted to set up more, what do I do with the line

for i = 1, #b do
a[#a+1] = b[i]
end

Report Abuse
LordSymphonic is not online. LordSymphonic
Joined: 20 Jun 2012
Total Posts: 101
25 Jun 2012 02:24 PM
I would use pairs and do:

    for _, a in pairs(Workspace.SuperSoldier44:GetChildren()) do
    if a:IsA("Model") then
    for _, b in pairs(a:GetChildren()) do
    if b:IsA("BasePart") then
    b.Transparency = 0.6
    end
    end
    end
    end

Basically, that will turn all of the models' inside "SuperSoldier44" part's Transparency to 0.6.
Report Abuse
noobertuber is not online. noobertuber
Joined: 16 Jan 2007
Total Posts: 2321
25 Jun 2012 02:26 PM
Well, there are a few things you could do. Probably the simplest one is to do the following for each other get children statement:

b = game.Workspace.SuperSoldier44.Arm1:getChildren()
for i = 1, #b do
a[#a+1] = b[i]
end

Just paste that code for each one, changing b to equal the new thing Get Children statement.

-God Bless-
Report Abuse
SuperSoldier44 is not online. SuperSoldier44
Joined: 13 Jun 2012
Total Posts: 37
25 Jun 2012 02:31 PM
@LordSymphonic

I would use that script, but then certain parts are affected (Specifically I'm saying my weapon gets holstered, and 1 part named "ShellOut" becomes visable, when it isn't)
Report Abuse
blobbyblob is not online. blobbyblob
Joined: 29 Oct 2008
Total Posts: 12165
25 Jun 2012 02:53 PM
Check this out! I wrote an 'mpairs' function which is just like pairs, except you can give it multiple tables.


function mpairs(...)
local x,a,b,t,i = {...},nil,nil,nil,nil;
i,t = next(x, t);
return function()
a,b = next(t, a);
while a==nil and b==nil and i~=nil and t~=nil do
i,t = next(x, i);
if t~=nil then
a,b=nil, nil;
a,b = next(t, a);
end
end
return a,b;
end;
end

t = {"Hello", t="World"};
t2 = {[0] = "Hey", [1] = "How", [2] = "Are", [3] = "You?"}
for x,y in mpairs(t, t2) do
print(x,y);
end

Prints:
1 Hello
t World
0 Hey
1 How
3 You?
2 Are
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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