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: To check of existence.

Previous Thread :: Next Thread 
hansotto is not online. hansotto
Joined: 21 Apr 2010
Total Posts: 233
10 Mar 2014 02:50 PM
How do you check if something exists?
like, if you want a function to run only when a special brick IS in the Workspace.
How would i do this?
Report Abuse
CrniOrao is not online. CrniOrao
Joined: 12 Oct 2008
Total Posts: 2274
10 Mar 2014 02:52 PM
How special is the brick? Wedge, Truss or specially named?
Report Abuse
GamingOwl is not online. GamingOwl
Joined: 18 Feb 2014
Total Posts: 350
10 Mar 2014 02:52 PM
I think he wants a certain name...
Report Abuse
hansotto is not online. hansotto
Joined: 21 Apr 2010
Total Posts: 233
10 Mar 2014 02:53 PM
Yea, name.
Report Abuse
CrniOrao is not online. CrniOrao
Joined: 12 Oct 2008
Total Posts: 2274
10 Mar 2014 02:54 PM
To check if it's there, by name you'd go like this:

if Workspace:findFirstChild("NameOfBrick") then
-- Do stuff
end

And if you're searching by a type of it, then use :IsA("") method.
Report Abuse
hansotto is not online. hansotto
Joined: 21 Apr 2010
Total Posts: 233
10 Mar 2014 02:55 PM
Okay, Thanks
Report Abuse
LemmJuice is not online. LemmJuice
Joined: 23 Feb 2014
Total Posts: 866
10 Mar 2014 02:55 PM
if (workspace:findFirstChild("NAMEHERE")) then
--do stuff in here
end



or if you mean when a brick is added

workspace.ChildAdded:connect(function (child)
if (child.Name == "NAMEHERE") then
--do stuff
end
end)
Report Abuse
LilMcManiac is not online. LilMcManiac
Joined: 31 Oct 2011
Total Posts: 2812
10 Mar 2014 03:37 PM
S = game.Workspace:findFirstChild("Special Brick")
if S == nil then
--Things here
end
Report Abuse
CrniOrao is not online. CrniOrao
Joined: 12 Oct 2008
Total Posts: 2274
10 Mar 2014 03:48 PM
^ Odd, you're checking if it isn't there then do stuff. Why so? :D
Report Abuse
Duelingwarlord is not online. Duelingwarlord
Joined: 15 Feb 2010
Total Posts: 22333
10 Mar 2014 04:06 PM
if item then
--code
end
Report Abuse
crazyman32 is not online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
10 Mar 2014 04:31 PM
sad;kajs;dfkldjf, capitalize the F!

findFirstChild is deprecated.

Use FindFirstChild.


Is there a difference? No. But in the real world, when something is deprecated, it should never be used (in the case there is a difference).

Plus it looks better :)
Report Abuse
LemmJuice is not online. LemmJuice
Joined: 23 Feb 2014
Total Posts: 866
10 Mar 2014 04:33 PM
findFirstChild and FindFirstChild makes no difference?
Report Abuse
crazyman32 is not online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
10 Mar 2014 04:35 PM
No difference

ROBLOX recently changed most of their methods from 'camelCase' to 'PascalCase,' and deprecated all the 'camelCase' methods.

From what I (and other peeps) see, there is no difference. At the very least, they output the same result.
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