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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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 |
|
|