Mezur
|
  |
| Joined: 29 Jun 2015 |
| Total Posts: 3040 |
|
|
| 26 Jun 2016 10:14 PM |
It works how I wanted it to work BUT I want it so the wheels and what not, do not get colored and so they remain black. Any idea on how to make certain parts of the vehicle remain their original color?
model = workspace.Jeep bin = script.Parent
function onTouched(part) if (model.Name == "Jeep") then for index, part in pairs(model:GetChildren()) do part.BrickColor = script.Parent.BrickColor end end end connection = bin.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
Mezur
|
  |
| Joined: 29 Jun 2015 |
| Total Posts: 3040 |
|
| |
|
Mezur
|
  |
| Joined: 29 Jun 2015 |
| Total Posts: 3040 |
|
| |
|
Mezur
|
  |
| Joined: 29 Jun 2015 |
| Total Posts: 3040 |
|
| |
|
|
| 26 Jun 2016 10:18 PM |
If you're not using meshes, just include a check in each iteration in the for loop to see if the part is a Cylinder or not.
if not (part.Shape == Enum.Shape.Cylinder) then -- code here end |
|
|
| Report Abuse |
|
|
Mezur
|
  |
| Joined: 29 Jun 2015 |
| Total Posts: 3040 |
|
|
| 26 Jun 2016 10:21 PM |
| I want it so all parts that are NOT named "Block" will not get colored. |
|
|
| Report Abuse |
|
|
Mezur
|
  |
| Joined: 29 Jun 2015 |
| Total Posts: 3040 |
|
|
| 26 Jun 2016 10:22 PM |
| Not sure how to do that... Also i'm not using any mesh |
|
|
| Report Abuse |
|
|
Mezur
|
  |
| Joined: 29 Jun 2015 |
| Total Posts: 3040 |
|
|
| 26 Jun 2016 10:26 PM |
I want all the parts in "Jeep" that are called "Block" to get colored.. This is what I have so far, and it's not working.
model = workspace.Jeep.Block bin = script.Parent
function onTouched(part) if (model.Name == "Block") then for index, part in pairs(model:GetChildren()) do part.BrickColor = script.Parent.BrickColor end end end connection = bin.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
Mezur
|
  |
| Joined: 29 Jun 2015 |
| Total Posts: 3040 |
|
| |
|
|
| 26 Jun 2016 10:37 PM |
@Mezur You were close; you should've put the 'if' inside the for loop. Here's an example code below:
for i, v in pairs(ASSET) do if v.Name == 'Block' and v:IsA('BasePart') then -- What if there was an asset that wasn't a Part in the model, and is named 'Block' too? v.BrickColor = BrickColor.new('Really red') end end
Thanks for reading, and have a nice day. :) |
|
|
| Report Abuse |
|
|
Qraotic
|
  |
| Joined: 12 Mar 2016 |
| Total Posts: 63 |
|
|
| 26 Jun 2016 10:38 PM |
check if the name is "Block" in the pairs loop
for _,part in pairs(model) do if part.Name=="Block" then part.BrickColor=BrickColor.Black() end end |
|
|
| Report Abuse |
|
|
Mezur
|
  |
| Joined: 29 Jun 2015 |
| Total Posts: 3040 |
|
|
| 26 Jun 2016 10:39 PM |
| i figured it out. my problem was actually pretty simple lol. |
|
|
| Report Abuse |
|
|
Crimsonal
|
  |
| Joined: 23 Apr 2011 |
| Total Posts: 1795 |
|
|
| 26 Jun 2016 10:43 PM |
Idk what you're trying to do here and I see you've been having this problem for awhile now, But try this:
script.Parent.Touched:connect(function(part) if part.Parent.Name == "Jeep" then for i,v in pairs(part.Parent:GetChildren()) do if v.Name == "Block" then v.BrickColor = script.Parent.BrickColor end end end end) |
|
|
| Report Abuse |
|
|