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: FindFirstChild not working

Previous Thread :: Next Thread 
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
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
InedibleGames is not online. InedibleGames
Joined: 27 Apr 2014
Total Posts: 1140
19 Apr 2015 07:44 AM
Bush isn't inside the the model...
Report Abuse
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
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
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
19 Apr 2015 07:49 AM
an if statement*
Report Abuse
InedibleGames is not online. InedibleGames
Joined: 27 Apr 2014
Total Posts: 1140
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
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
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
InedibleGames is not online. InedibleGames
Joined: 27 Apr 2014
Total Posts: 1140
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
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
19 Apr 2015 07:54 AM
So if the BerryBush doesn't exist, destroy it? nty.
Report Abuse
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
19 Apr 2015 07:55 AM
didn't see the "not" lol will try it
Report Abuse
lokkut is not online. lokkut
Joined: 18 Mar 2009
Total Posts: 1794
19 Apr 2015 07:55 AM
are you sure that's line 47?
Report Abuse
Hibobb is not online. 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
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
19 Apr 2015 07:56 AM
Still errors.

Yep, it's line 47 according to output.
Report Abuse
lokkut is not online. 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 is not online. 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 is not online. 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
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
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
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
19 Apr 2015 08:42 AM
b
Report Abuse
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
19 Apr 2015 09:10 AM
b2
Report Abuse
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
19 Apr 2015 09:23 AM
b3 brb
Report Abuse
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
19 Apr 2015 09:35 AM
b4 brb
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