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: Comparing a nil to a number value?

Previous Thread :: Next Thread 
DoctorHelix is not online. DoctorHelix
Joined: 05 May 2015
Total Posts: 303
23 Jun 2015 05:01 PM
For some reason I get this output,

Output:

attempt to compare nil with a number

This is the line

if Player.PlayerGui:FindFirstChild("GameHUD").Points.Points.Value > highscore then

Yes, highscore is a variable for a number. highscore = 0.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
23 Jun 2015 05:02 PM
.Points.Points? Are you sure that's right?
Report Abuse
BJCarpenter is online. BJCarpenter
Joined: 04 Nov 2008
Total Posts: 4416
23 Jun 2015 05:05 PM
print(Player.PlayerGui:FindFirstChild("GameHUD").Points.Points.Value, highscore)
if Player.PlayerGui:FindFirstChild("GameHUD").Points.Points.Value > highscore then

Report Abuse
DoctorHelix is not online. DoctorHelix
Joined: 05 May 2015
Total Posts: 303
23 Jun 2015 05:13 PM
Yes, points.points is right. Points is the name of a textlabel, and the second points is an intvalue.
Report Abuse
DoctorHelix is not online. DoctorHelix
Joined: 05 May 2015
Total Posts: 303
23 Jun 2015 05:15 PM
Also, it works sometimes. Sometimes it works, sometimes it doesn't.
Report Abuse
DoctorHelix is not online. DoctorHelix
Joined: 05 May 2015
Total Posts: 303
23 Jun 2015 05:33 PM
Bump.
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
23 Jun 2015 05:36 PM
Either points.Value is nil or highscore is nil. Points.Value should under no circumstances be nil.

if (highscore == nil) or (Player.PlayerGui:FindFirstChild("GameHUD").Points.Points.Value > highscore) then

Comparing highscore to nil is far more readable and far more reasonable than using "not" where it doesn't belong.
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