|
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 08 Nov 2015 12:26 AM |
@lordrambo
Thanks! It helped a lot!
-zachattack220 |
|
|
| Report Abuse |
|
|