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: Would this script correctly rename?

Previous Thread :: Next Thread 
zub74 is not online. zub74
Joined: 13 Sep 2008
Total Posts: 489
11 Jun 2014 10:47 PM
for i,v in pairs(Workspace.Car:GetChildren()) do
if v.Name=Handle then
return
else v.Name = "Part"
end

I don't have a whole lot of experience with the in pairs thing, but is anything wrong with this script? The purpose would be to rename all children of the model Car Part, unless the name was Handle.
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
11 Jun 2014 10:49 PM
if v.Name=Handle then
should be
if v.Name == "Handle" then

You use == to compare two things, and Handle is a string, so it needs quotes around it

-[::ƧѡÎḾḠΰῩ::]-[::Helper of Scripting and Writer of Wikis::]
Report Abuse
JoshuaKempfert is not online. JoshuaKempfert
Joined: 16 Feb 2013
Total Posts: 2407
11 Jun 2014 10:50 PM
No, first of all because using the = operator is setting the value, using the == is comparing the two to see if they are equal. Plus return would stop the loop. Also the name handle is a string.

for i,v in pairs(Workspace.Car:GetChildren()) do
if v.Name ~= "Handle" then -- ~= returns true if they are not equal
v.Name = "CarPart" -- you said you wanted the name to be car part right?
end
end
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