[lua\includes\extensions\math.lua:218] attempt to compare number with nil error?
1 replies, posted
Hi. I'm trying to finish my SENT for toybox up. But every time I use it, this error SPAMS in my console:
[lua\includes\extensions\math.lua:218] attempt to compare number with nil
In orange and blue text. I have NO clue how to fix this because the error takes place in a file that isn't even included with my entity. I found the math.lua in the garrysmod content.fgd, and at line 218, there's a function. I'll paste the function.
[code]function math.Approach( cur, target, inc )
inc = math.abs( inc )
if (cur < target) then
return math.Clamp( cur + inc, cur, target )
elseif (cur > target) then
return math.Clamp( cur - inc, target, cur )
end
return target
end[/code]
Please, I need help. It's one of the most annoying errors I've encountered. Thanks ahead of time.
[B]EDIT:[/B]
I searched my code "math.Approach" and I found 3 results. I'll try to fix them.
[B]EDIT:[/B]
Couldn't fix it. Still need help. :/
Give us the code that is calling the math.Approach (the whole function that contains math.Approach) and we may be able to help.
You're getting the error because a value you are passing to math.Approach is nil.
Either let us see the code, or try and add checks to ensure that the variables you are passing are [I]not[/I] nil.
Sorry, you need to Log In to post a reply to this thread.