Turbesz Posted July 5, 2021 Share Posted July 5, 2021 I made a nametag system. And i have these calculations in the code: local width, height = 400*scale, 400*scale local sx, sy = sx-width/2.2, sy-height The debugscript sometimes spam a error message with the "local sx, sy..." line.. "Attempt to perform arithmetic on a boolean value". But the code works fine... Wth? What wrong? These calculations needed for the script. Link to comment
DiSaMe Posted July 6, 2021 Share Posted July 6, 2021 Did you try outputting the variable values and tracking down where the booleans get introduced? I assume you're using getScreenFromWorldPosition, assigning the return values to sx and sy and not checking those values. The thing is, if the point is off screen, that means there isn't a valid position on the screen for that point, and the function returns false (edgeTolerance argument can prevent this for some positions, but the function will still return false if the point is behind the camera). So false and nil get assigned to sx and sy respectively, and then you attempt to subtract from those values. That's where the error comes from. If you only draw one nametag in that event handler, it makes sense that it appears to work fine, because the error only occurs in cases where the nametag wouldn't be visible anyway. 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now