|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|