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: FindFirstChild through a table?

Previous Thread :: Next Thread 
ExoCross is not online. ExoCross
Joined: 26 Jan 2011
Total Posts: 179
01 Feb 2012 04:33 PM
Is this possible?

My try:

table = {apple, orange, grapes}

if player.Backpack:FindFirstChild(table) then

?

† KMXD †
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
01 Feb 2012 04:39 PM
No. You can do something like this though.

table = {"apples","orange","grapes"}
for i,v in pairs(table) do
if player.Backpack:FindFirstChild(v) then
--code
end
end
Report Abuse
ExoCross is not online. ExoCross
Joined: 26 Jan 2011
Total Posts: 179
01 Feb 2012 04:41 PM
Cool, so if there;s more than one item in the table in the backpack, the one that shows up first will be picked? Eh doesn't matter, I'll just access it from backpack, to ensure there;s only one :P
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
01 Feb 2012 04:43 PM
That'll go through all the things in the table and if anything in that table is in the Backpack then it'll run the code. Not the first thing that comes up anything that comes up.
Report Abuse
ExoCross is not online. ExoCross
Joined: 26 Jan 2011
Total Posts: 179
01 Feb 2012 04:50 PM
Another thing, can you clone things multiple times?

Like a = game.Lighting.Apple:Clone()
a.Parent = workspace

Could you clone "a" (apple) again?
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
01 Feb 2012 04:53 PM
You can clone things multiply times but you HAVE to clone them.

Example.


a = game.Lighting.Apple:Clone()
a.Parent = workspace

That example would work. Though if you did something like this

a = game.Lighting.Apple
a.Parent = Workspace

You can't clone that from lighting anymore because it's already in Workspace and you forgot to clone it.


Btw you can just say this.

game.Lighting.Apple:Clone().Parent = Workspace
Report Abuse
flappydavid is not online. flappydavid
Joined: 03 May 2009
Total Posts: 5893
01 Feb 2012 04:58 PM
table = {"apple","pear","idk"}
tab = table[math.random(1,#table)]
tabular = game.Lighting:FindFirstChild(tab)
if tabular then
tabular:clone().Parent = game.Workspace
end
Report Abuse
ExoCross is not online. ExoCross
Joined: 26 Jan 2011
Total Posts: 179
01 Feb 2012 05:05 PM
So would this work?

a = game.Lighting.Apple
a:Clone().Parent = workspace
a:Clone().Parent = workspace

?
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
01 Feb 2012 05:06 PM
@flappy

Why not let him try to figure it out himself first?
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
01 Feb 2012 05:07 PM
@exor

Yes, yes it would.
Report Abuse
ExoCross is not online. ExoCross
Joined: 26 Jan 2011
Total Posts: 179
01 Feb 2012 05:08 PM
@Flap

Thanks, but no. These questions aren't related. Though how would you clone more than 1 thing in workspace?
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
01 Feb 2012 05:09 PM
@exorcross

Either keep on rewriting that simple 1 line code or a for loop.
Report Abuse
ExoCross is not online. ExoCross
Joined: 26 Jan 2011
Total Posts: 179
01 Feb 2012 05:11 PM
Oh, so just

for i = 1, 5 do
local a = game.Lighting:FindFirstChild("Apple")
a.Parent = workspace
end

?
Report Abuse
dirk29 is not online. dirk29
Joined: 26 May 2010
Total Posts: 1142
01 Feb 2012 05:13 PM
Yes, that's correct.
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
01 Feb 2012 05:14 PM
for i = 1,5 do
a = game.Lighting.Apple
a:Clone().Parent = Workspace
end


Remember what I said? If you don't clone it it would error because it wouldn't be in Lighting anymore it would be in Workspace.
Report Abuse
ExoCross is not online. ExoCross
Joined: 26 Jan 2011
Total Posts: 179
01 Feb 2012 05:19 PM
Oh, lol, keep forgeting xD
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
01 Feb 2012 05:20 PM
Simple mistake ;)
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