|
| 05 Apr 2015 02:38 AM |
| If I wanted to do FindFirstChild but make the search directed by a Class Name how would I go about this? |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 05 Apr 2015 02:46 AM |
That does not even make sense, what would you do if there were multiple objects with the same classname?
I script -~ chimmihc |
|
|
| Report Abuse |
|
|
MiniNob
|
  |
| Joined: 14 May 2013 |
| Total Posts: 822 |
|
|
| 05 Apr 2015 03:14 AM |
function getchildrenbyclassname(dir,class) local tab={} for i,v in pairs(dir:children()) do if v.className==class then table.insert(tab,v)end end return tab end |
|
|
| Report Abuse |
|
|
jtefurd
|
  |
| Joined: 01 May 2010 |
| Total Posts: 952 |
|
|
| 05 Apr 2015 03:20 AM |
Something like this?
for i,v in pairs game.Workspace:GetChildren() do if i:IsA("Model") do print(i.Name.." is a model!") end end
|
|
|
| Report Abuse |
|
|
|
| 05 Apr 2015 05:35 AM |
Two options.
:IsA("ClassName" or "Inherited"), .ClassName == "ClassName"
http://wiki.roblox.com/index.php?title=API:Instance/IsA |
|
|
| Report Abuse |
|
|
|
| 05 Apr 2015 06:21 AM |
function FindFirstClass(object, class) for i,v in pairs(object:GetChildren()) do if v:IsA(class) then return v end end end
--Finds the first object in a given object's children with a specified class. |
|
|
| Report Abuse |
|
|
GOLDC3PO
|
  |
| Joined: 31 May 2011 |
| Total Posts: 509 |
|
|
| 05 Apr 2015 07:10 AM |
function FindFirstClass(object, class,recursive) for i,v in pairs(object:GetChildren()) do if v:IsA(class) then return v elseif recursive then return FindFirstClass(v, class) else return nil end end end |
|
|
| Report Abuse |
|
|