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 » Scripting Helpers
Home Search
 

Re: QUICK EASY HELP

Previous Thread :: Next Thread 
Vyzen is not online. 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 is not online. 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 is not online. 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 is not online. Vyzen
Joined: 23 Oct 2013
Total Posts: 4039
05 Nov 2013 07:27 PM
I fixed the colors also.
Report Abuse
lupine is not online. 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 is not online. 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 is not online. Vyzen
Joined: 23 Oct 2013
Total Posts: 4039
05 Nov 2013 07:33 PM
b1
Report Abuse
Bebee2 is not online. 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 is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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