|
| 19 Apr 2015 07:42 AM |
Okay, I have a script where 3 people are gathering berries but for some reason FindFirstChild isn't working properly (or how I thought it worked)...
if script.Parent.Parent:FindFirstChild("Bush") ~= nil then script.Parent.Parent:FindFirstChild("Bush"):Destroy() end
So... if the Bush still exists, destroy the bush? I'm getting an error on the other 2 players because they're trying to destroy the bush too...
13:39:59.526 - Bush is not a valid member of Model 13:39:59.527 - Script 'Workspace.BerryBush.collectpos.BerryScript', Line 47 13:39:59.528 - Stack End
I thought FindFirstChild() would prevent an error if it didn't exist? |
|
|
| Report Abuse |
|
|
|
| 19 Apr 2015 07:44 AM |
| Bush isn't inside the the model... |
|
|
| Report Abuse |
|
|
|
| 19 Apr 2015 07:48 AM |
| Yeah I know that's why I'm using and if statement checking with a FindFirstChild to check if it exists or not, It doesn't exist inside the model but it shouldn't give me an error because I used FindFirstChild() to check it right? |
|
|
| Report Abuse |
|
|
| |
|
|
| 19 Apr 2015 07:49 AM |
if script.Parent.Parent:FindFirstChild("Bush") ~= nil then script.Parent.Parent:FindFirstChild("Bush"):Destroy() else -- Do nothing end |
|
|
| Report Abuse |
|
|
|
| 19 Apr 2015 07:50 AM |
Nope, still errors.
if script.Parent.Parent:FindFirstChild("Bush") ~= nil then that is the line 47 btw |
|
|
| Report Abuse |
|
|
|
| 19 Apr 2015 07:53 AM |
if not script.Parent.Parent:FindFirstChild("Bush") ~= nil then -- Do nothing else script.Parent.Parent:FindFirstChild("Bush"):Destroy() end |
|
|
| Report Abuse |
|
|
|
| 19 Apr 2015 07:54 AM |
| So if the BerryBush doesn't exist, destroy it? nty. |
|
|
| Report Abuse |
|
|
|
| 19 Apr 2015 07:55 AM |
| didn't see the "not" lol will try it |
|
|
| Report Abuse |
|
|
lokkut
|
  |
| Joined: 18 Mar 2009 |
| Total Posts: 1794 |
|
|
| 19 Apr 2015 07:55 AM |
| are you sure that's line 47? |
|
|
| Report Abuse |
|
|
Hibobb
|
  |
| Joined: 18 Apr 2010 |
| Total Posts: 2146 |
|
|
| 19 Apr 2015 07:56 AM |
local bush = script.Parent.Parent:FindFirstChild("Bush") if bush then bush:Destroy() end
Alpha release of my game. Send me any bugs you find with the gun. http://www.roblox.com/games/200667607/Sniper-Stuff-ALPHA |
|
|
| Report Abuse |
|
|
|
| 19 Apr 2015 07:56 AM |
Still errors.
Yep, it's line 47 according to output. |
|
|
| Report Abuse |
|
|
lokkut
|
  |
| Joined: 18 Mar 2009 |
| Total Posts: 1794 |
|
|
| 19 Apr 2015 07:57 AM |
stop re-arranging the code.
it won't help. |
|
|
| Report Abuse |
|
|
lokkut
|
  |
| Joined: 18 Mar 2009 |
| Total Posts: 1794 |
|
|
| 19 Apr 2015 07:57 AM |
| No, i mean did you copy line 47 into the forum? |
|
|
| Report Abuse |
|
|
Hibobb
|
  |
| Joined: 18 Apr 2010 |
| Total Posts: 2146 |
|
|
| 19 Apr 2015 07:57 AM |
Sometimes that helps for me. He meant are you sure you posted line 47
Alpha release of my game. Send me any bugs you find with the gun. http://www.roblox.com/games/200667607/Sniper-Stuff-ALPHA |
|
|
| Report Abuse |
|
|
|
| 19 Apr 2015 07:57 AM |
"local bush = script.Parent.Parent:FindFirstChild("Bush") if bush then bush:Destroy() end"
still errors, brb shower. |
|
|
| Report Abuse |
|
|
lokkut
|
  |
| Joined: 18 Mar 2009 |
| Total Posts: 1794 |
|
|
| 19 Apr 2015 07:58 AM |
| Hibobb, if it helped then you wrote something wrong in the first place, there was nothing wrong with the code. |
|
|
| Report Abuse |
|
|
Hibobb
|
  |
| Joined: 18 Apr 2010 |
| Total Posts: 2146 |
|
|
| 19 Apr 2015 07:59 AM |
Did you create "Bush" locally in a FE enabled place and then are you trying to remove it with a server script? If so it doesn't exist on the server.
Alpha release of my game. Send me any bugs you find with the gun. http://www.roblox.com/games/200667607/Sniper-Stuff-ALPHA |
|
|
| Report Abuse |
|
|
Hibobb
|
  |
| Joined: 18 Apr 2010 |
| Total Posts: 2146 |
|
|
| 19 Apr 2015 08:00 AM |
Personally I think it cleans the code up as well but whatever.
Alpha release of my game. Send me any bugs you find with the gun. http://www.roblox.com/games/200667607/Sniper-Stuff-ALPHA |
|
|
| Report Abuse |
|
|
lokkut
|
  |
| Joined: 18 Mar 2009 |
| Total Posts: 1794 |
|
|
| 19 Apr 2015 08:01 AM |
| I'll admit it cleans it up, but shouldn't make any difference to anything but performance and legibility. |
|
|
| Report Abuse |
|
|
|
| 19 Apr 2015 08:32 AM |
Back.
Nope, I'm running FilteringEnabled but this is a server script and the bush is inside the server. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
| |
|