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
|
  |
| 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
|
  |
| Joined: 18 Feb 2014 |
| Total Posts: 350 |
|
|
| 10 Mar 2014 02:52 PM |
| I think he wants a certain name... |
|
|
| Report Abuse |
|
|
hansotto
|
  |
| Joined: 21 Apr 2010 |
| Total Posts: 233 |
|
| |
|
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
|
  |
| Joined: 21 Apr 2010 |
| Total Posts: 233 |
|
| |
|
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 |
|
|
|
| 10 Mar 2014 03:37 PM |
S = game.Workspace:findFirstChild("Special Brick") if S == nil then --Things here end |
|
|
| Report Abuse |
|
|
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 |
|
|
| |
|
|
| 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
|
  |
| Joined: 23 Feb 2014 |
| Total Posts: 866 |
|
|
| 10 Mar 2014 04:33 PM |
| findFirstChild and FindFirstChild makes no difference? |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|