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
 

Re: FindFirstChild()

Previous Thread :: Next Thread 
crate109 is not online. crate109
Joined: 24 Nov 2010
Total Posts: 315
20 Dec 2014 10:34 PM
Hello guys! FindFirstChild(string) gets me the first child of a model, but I would like to get all item that has the same name in the model. I could change the name of the part everytime I FindFIrstChild, but I have to activate the function only once (OnLoad)
What could I do please?
Report Abuse
Tauritaar is not online. Tauritaar
Joined: 30 Dec 2012
Total Posts: 1785
20 Dec 2014 10:37 PM
model = workspace.Model
for i = 1,#model do
if model[i].Name == "SameName" then
--stuff--
end
end
Report Abuse
GodShowsTheWay is not online. GodShowsTheWay
Joined: 27 Oct 2014
Total Posts: 7180
20 Dec 2014 10:40 PM
model = game.Workspace.Model
for i, v in ipairs(model:GetChildren()) do
if v.Name == "SameName" then
--stuff--
end
end
Report Abuse
IDKBlox is not online. IDKBlox
Joined: 05 Apr 2013
Total Posts: 1304
20 Dec 2014 10:41 PM
yeah pretty much that

x=script.Parent.Parts:GetChildren()

for i=1,#x do
if x[i].Name=="Taco" then
x[i].Transparency=.5
x[i].BrickColor=BrickColor.new("Really blue")
end
end

lol thats what i did XD
This changes the transparency to 1 and the color to blue, with all the names of taco
Report Abuse
crate109 is not online. crate109
Joined: 24 Nov 2010
Total Posts: 315
20 Dec 2014 10:41 PM
Ah that's what I thought :P Works thank you :) I had to make 2 loops because I had to select all trees from my place, then all leaves from all these trees :S I think I spelled something wrong, but whatever it works now lol!
Report Abuse
crate109 is not online. crate109
Joined: 24 Nov 2010
Total Posts: 315
20 Dec 2014 10:44 PM
function WinterTrees()
allTrees = game.Workspace.Trees:GetChildren()
for i = 1, #allTrees do
if allTrees then
part = allTrees[i]:GetChildren()
for e = 1, #part do
if part then
if part[e].Name == "TreeLeaf" then
part[e].BrickColor = BrickColor.new("White")
end
end
end
end

end
end
game.Loaded:connect(WinterTrees)


Well, this script is a bit useless lol cause I could just change the color of the leaves manually, considering I only have 3 trees :P But no.
Report Abuse
crate109 is not online. crate109
Joined: 24 Nov 2010
Total Posts: 315
20 Dec 2014 11:04 PM
Finally, I decided to use if (part[e].BrickColor = BrickColor.new(color), so I can change the summer color of the leaves :P If I kept the name condition I'd have to change names of all trees leaves :3
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