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() not working?

Previous Thread :: Next Thread 
MattDominator is not online. MattDominator
Joined: 20 Oct 2008
Total Posts: 3981
20 Jul 2014 04:23 PM
I've been trying to get this function to work, but the if statements aren't firing. BotScript is in ServerScriptService and Robot is in the Robots model, so it should be working fine. I'm really not sure what's wrong:

_G["RobotBuilding"] = function(BotScript,Robot)

print(BotScript.Parent.Name) -- ServerScriptService
print(Robot.Parent.Name) -- Robots

if game.ServerScriptService:FindFirstChild(BotScript) then
print("FoundScript") -- Doesn't print
end
if game.Workspace.Lobby.Robots:FindFirstChild(Robot) then
print("FoundRobot") -- Doesn't print
end

end

I've only just started to use Global functions, so I'm assuming it has something to do with that?
Report Abuse
Tynexx is not online. Tynexx
Joined: 11 Jul 2012
Total Posts: 1559
20 Jul 2014 04:25 PM
~=nil then?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
20 Jul 2014 04:25 PM
It's working fine, but looking at your script it appears BotScript isn't a string but an object.
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
20 Jul 2014 04:27 PM
^
This. FindFirstChild requires a string. Also, in your declaration of the global function, the brackets and quotes aren't necessary.
Report Abuse
MattDominator is not online. MattDominator
Joined: 20 Oct 2008
Total Posts: 3981
20 Jul 2014 04:33 PM
Thanks guys.
Report Abuse
Krypticon is not online. Krypticon
Joined: 12 Feb 2014
Total Posts: 680
20 Jul 2014 04:43 PM
@blockoo FindFirstChild doesn't require a string :)
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
20 Jul 2014 04:45 PM
Yes it does.
Report Abuse
Krypticon is not online. Krypticon
Joined: 12 Feb 2014
Total Posts: 680
21 Jul 2014 01:04 PM
I use FindFirstChild without a string regularly though, like:

local players=Game.Players:GetPlayers()
local selected=players[math.random(1,#players))
local target=Game.Workspace:FindFirstChild(selected.Name)

etc.

And btw, I know the code is ineffective, it's purely an example I made of the top of my head. :)
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
21 Jul 2014 04:25 PM
That's still using a string. selected.Name is a string.
Report Abuse
brinkokevin is not online. brinkokevin
Joined: 25 Jul 2012
Total Posts: 1673
21 Jul 2014 04:28 PM
where is this script ?? is it in serverscriptstorage ?? then dont do game.ServerScriptService use script.Parent if the script is somewhere else then u cant find anything that is in serverscriptstorage because its locked other scripts cant see it
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