Vyzen
|
  |
| Joined: 23 Oct 2013 |
| Total Posts: 4039 |
|
|
| 05 Nov 2013 07:20 PM |
I used to be an intermediate scripter in lua, and I used to be able to do the in pairs function really well, now I don't know how to anymore
I'm trying to do a script in studio that changes all the bricks that are Dark Stone Gray into black.
for i,v in pairs() if game.Workspace.v.BrickColor = "Dark Stone Gray" then game.Workspace.v.BrickColor = "Black" end |
|
|
| Report Abuse |
|
|
lupine
|
  |
| Joined: 24 Jun 2008 |
| Total Posts: 3561 |
|
|
| 05 Nov 2013 07:24 PM |
the 'for var1,var2 in pairs()' cycles through a TABLE of elements, so you'll need to do something like
for i,v in pairs(workspace:GetChildren()) do --because :GetChildren() returns a table if v.BrickColor == BrickColor.new("Dark Stone Gray") then v.BrickColor = BrickColor.new("Black") end
Also, you were comparing BrickColor values to string values. |
|
|
| Report Abuse |
|
|
Vyzen
|
  |
| Joined: 23 Oct 2013 |
| Total Posts: 4039 |
|
|
| 05 Nov 2013 07:26 PM |
| Alright thanks, but I tried to put that into the command bar and nothing happened. |
|
|
| Report Abuse |
|
|
Vyzen
|
  |
| Joined: 23 Oct 2013 |
| Total Posts: 4039 |
|
| |
|
lupine
|
  |
| Joined: 24 Jun 2008 |
| Total Posts: 3561 |
|
|
| 05 Nov 2013 07:27 PM |
| It needs another 'end' at the very end, sorry. |
|
|
| Report Abuse |
|
|
Vyzen
|
  |
| Joined: 23 Oct 2013 |
| Total Posts: 4039 |
|
|
| 05 Nov 2013 07:29 PM |
for i,v in pairs(workspace:GetChildren()) do if v.BrickColor == BrickColor.new("Dark stone gray") then v.BrickColor = BrickColor.new("Really black") end end
19:30:27.240 - BrickColor is not a valid member of Model 19:30:27.241 - Script 'for i,v in pairs(workspace:GetChildren()) do if v.BrickColo', Line 2 19:30:27.243 - stack end |
|
|
| Report Abuse |
|
|
Vyzen
|
  |
| Joined: 23 Oct 2013 |
| Total Posts: 4039 |
|
| |
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 05 Nov 2013 07:34 PM |
for i,v in pairs(workspace:GetChildren()) do if v:IsA'BasePart' then if v.BrickColor == BrickColor.new("Dark stone gray") then v.BrickColor = BrickColor.new("Really black") end end end
|
|
|
| Report Abuse |
|
|
Vyzen
|
  |
| Joined: 23 Oct 2013 |
| Total Posts: 4039 |
|
|
| 05 Nov 2013 07:40 PM |
| That's odd. When I did it in studio it changed all the gray bricks name's to black, but didn't change their color... |
|
|
| Report Abuse |
|
|
Vyzen
|
  |
| Joined: 23 Oct 2013 |
| Total Posts: 4039 |
|
|
| 05 Nov 2013 07:40 PM |
| I mean like, it says they're "Really black", but they stay their same color. |
|
|
| Report Abuse |
|
|