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: ClassName

Previous Thread :: Next Thread 
RufusTulliusAurelius is not online. RufusTulliusAurelius
Joined: 25 Apr 2008
Total Posts: 438
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 is not online. 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 is not online. 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 is not online. 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
epicbreaker is not online. epicbreaker
Joined: 23 Apr 2011
Total Posts: 2791
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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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 is not online. 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
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