Presting
|
  |
| Joined: 16 Mar 2011 |
| Total Posts: 715 |
|
|
| 19 Jul 2014 08:56 AM |
I want to change the name of all bricks that are coloured "Dark stone grey" to "Stone" and all bricks that are coloured "Bright green" be named "Grass".
game.Workspace = world
if brick.Name = "Part" then
if world.Part.BrickColor = "Dark stone grey"
then world.Part.Name = "Stone"
if world.Part.BrickColor = "Bright green"
then world.Part.Name = "Grass"
end
|
|
|
| Report Abuse |
|
|
Presting
|
  |
| Joined: 16 Mar 2011 |
| Total Posts: 715 |
|
|
| 19 Jul 2014 09:02 AM |
So I tried this as well, but it didn't work either? :
if game.Workspace.Part.BrickColor = "Bright green" then game.Workspace.Part.Name = "Grass" else game.Workspace.Part.Name = "Stone" end |
|
|
| Report Abuse |
|
|
cornytime
|
  |
| Joined: 07 Feb 2013 |
| Total Posts: 3213 |
|
|
| 19 Jul 2014 09:04 AM |
| Part.BrickColor = BrickColor.new("Dark stone grey") |
|
|
| Report Abuse |
|
|
WishNite
|
  |
| Joined: 11 Feb 2009 |
| Total Posts: 15828 |
|
|
| 19 Jul 2014 09:05 AM |
function recurse(model) for i,v in ipairs(model:GetChildren()) do if v:IsA("Part") then if v.BrickColor == BrickColor.new("Dark stone grey") then v.Name = "Stone" elseif v.BrickColor = BrickColor.new("Bright green") then v.Name = "Grass" end end end recurse(model) end
recurse(workspace) |
|
|
| Report Abuse |
|
|
Presting
|
  |
| Joined: 16 Mar 2011 |
| Total Posts: 715 |
|
|
| 19 Jul 2014 09:15 AM |
@cornytime, I used yours like this but it only changed one brick name:
part = game.Workspace.Part
if part.BrickColor == BrickColor.new("Bright green") then game.Workspace.Part.Name = "Grass" else
if part.BrickColor == BrickColor.new("Dark stone grey") then game.Workspace.Part.Name = "Stone" end end
@WishNite, I tried yours and it did work, although gave some errors as well. |
|
|
| Report Abuse |
|
|
Presting
|
  |
| Joined: 16 Mar 2011 |
| Total Posts: 715 |
|
| |
|
Presting
|
  |
| Joined: 16 Mar 2011 |
| Total Posts: 715 |
|
|
| 19 Jul 2014 09:32 AM |
For those who want a working one, I tested out many version of WishNite's code and this one is the shortest and best way I could find (I think the extra functions he added were not necessary, but I don't know what they did honestly)
Here:
for i,v in pairs(game.Workspace:GetChildren()) do if v.Name == "Part" then if v.BrickColor == BrickColor.new("Bright green") then v.Name = "Grass" elseif v.BrickColor == BrickColor.new("Dark stone grey") then v.Name = "Stone" end end end
|
|
|
| Report Abuse |
|
|