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 » Scripters
Home Search
 

Re: :FindFirstChild, class?

Previous Thread :: Next Thread 
zachattack220 is not online. zachattack220
Joined: 20 Jan 2013
Total Posts: 2196
07 Nov 2015 11:52 PM
I need to find a hat class in something, how do i use :FindFirstChild with a class filter, such as "hat"?



-zachattack220
Report Abuse
petro180 is not online. petro180
Joined: 30 Mar 2009
Total Posts: 354
07 Nov 2015 11:55 PM
if game.Workspace:findFirstChild("RedCap") and game.Workspace:findFirstChild("RedCap"):IsA("Hat") then

--code here once it finds the hat

end
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
08 Nov 2015 12:03 AM
lol that makes an extra unnecessary function call

anyways OP you are going to have to run a loop

for i, v in pairs(something:GetChildren()) do
if v.Name == "whatever" and v:IsA("Hat") then
--code
end
end

I got rid of FindFirstChild, and the call to IsA is only made if the first condition is true (thanks to handy dandy short circuit evaluation).
Report Abuse
zachattack220 is not online. zachattack220
Joined: 20 Jan 2013
Total Posts: 2196
08 Nov 2015 12:26 AM
@lordrambo

Thanks! It helped a lot!



-zachattack220
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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