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: Debugging Help

Previous Thread :: Next Thread 
Wolfman11127 is not online. Wolfman11127
Joined: 27 Jul 2012
Total Posts: 132
15 Mar 2016 02:41 PM
Here are the lines of code I have been struggling with. I know for a fact the first two work because the print works, but I can't figure out why the last one won't work. I have checked and double checked that all of it's parents and everything are alined right and they are and it still doesn't work. I keep getting the error message in output of Players.Player1.PlayerGui.Leaderboard.Main.Challenge.LocalScript:14: attempt to index local 'target' (a nil value)

Here is my code.
local target = game.Workspace.PlayerDueling:FindFirstChild(Challengee)--Finds Challengee
print'found target'
target.Event1:FireServer() --Launch Event

Any help would be greatly appreciated.
Report Abuse
NovusTheory is not online. NovusTheory
Joined: 14 Oct 2009
Total Posts: 4532
15 Mar 2016 02:45 PM
It's not able to find game.Workspace.PlayerDueling[Challengee]
Report Abuse
Wolfman11127 is not online. Wolfman11127
Joined: 27 Jul 2012
Total Posts: 132
15 Mar 2016 02:47 PM
But it does because, it gives me the print message in output.
Report Abuse
NovusTheory is not online. NovusTheory
Joined: 14 Oct 2009
Total Posts: 4532
15 Mar 2016 02:51 PM
FindFirstChild will either return the child or nil if not found
Report Abuse
Locard is not online. Locard
Joined: 13 Apr 2014
Total Posts: 3516
15 Mar 2016 02:52 PM
FindFirstChild returns what you're trying to find or nil, meaning the code will still run. But if it returned nil, target will be nil. You got to check if target is nil or not.

local target = game.Workspace.PlayerDueling:FindFirstChild(Challengee)
if target then
target.Event1:FireServer() --Launch Event
else
print('couldn't find target!')
end
Report Abuse
Locard is not online. Locard
Joined: 13 Apr 2014
Total Posts: 3516
15 Mar 2016 02:53 PM
Novus you sneaky ninja.
Report Abuse
NovusTheory is not online. NovusTheory
Joined: 14 Oct 2009
Total Posts: 4532
15 Mar 2016 02:53 PM
Sorry Locard :)
Report Abuse
Wolfman11127 is not online. Wolfman11127
Joined: 27 Jul 2012
Total Posts: 132
15 Mar 2016 03:04 PM
Ok thanks for the help!
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