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: Number recognized as boolean?

Previous Thread :: Next Thread 
BrainSqueezer is not online. BrainSqueezer
Joined: 19 Aug 2009
Total Posts: 432
31 Mar 2014 08:45 PM
I'm trying to test the difference between two parts' lookVectors (specifically, the script's parent & the torso of a character), and am getting a weird error. This is part I'm focusing on:
-----------------------------------------
local char = hit.Parent
local torz = hit.Parent.Torso

local look = script.Parent.CFrame.lookVector
local lookAng = math.atan2(look.z, look.x)
lookAng = lookAng * (180 / math.pi)

local charLook = torz.CFrame.lookVector
local charLookAng = math.atan2(charLook.z, charLook.x)
charLookAng = charLookAng * (180 / math.pi)

local diffAng = lookAng - charLookAng
print(diffAng)

if (not diffAng < 10) and (not diffAng > -10) then
-----------------------------------------

The last line above is giving me a lot of trouble for some reason. I keep getting this error:
- attempt to compare boolean with number
What is being recognized as a boolean in that line? When I print 'diffAng' in the second-to-last line, it outputs as a number like it should.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
31 Mar 2014 08:51 PM
put the things after the nots in parenthesis.

if not (diffAng < 10) and not (diffAng > -10) then
Report Abuse
BrainSqueezer is not online. BrainSqueezer
Joined: 19 Aug 2009
Total Posts: 432
31 Mar 2014 08:56 PM
Whoa...I was just using parentheses to organize that line a little better. I didn't know that would actually change how it was read. I'll never underestimate them again.

Anyways, thanks! That got rid of the error :D
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
31 Mar 2014 09:16 PM
If you want, you could do this:

if (not (diffAng < 10)) and (not (diffAng > -10)) then

The problem you made was that it was doing "not diffAng" first, which would return true, so you are comparing true (bool) to a number
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
31 Mar 2014 09:19 PM
return false*
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