Self is a nil value
Posted: Sat Aug 31, 2024 9:16 pm
I was following a series of tutorials on how to create a platformer when I got to the point where you're supposed to draw the player aka a rectangle. I followed along and pressed alt + l to see it run when I got this error:
Error
Player.lua:31: bad argument #2 to 'rectangle' (number expected, got nil)
Traceback
[love "callbacks.lua"]:228: in function 'handler'
[C]: in function 'rectangle'
Player.lua:31: in function 'draw'
main.lua:20: in function 'draw'
[love "callbacks.lua"]:168: in function <[love "callbacks.lua"]:144>
[C]: in function 'xpcall'
I triple checked my code and It should work, but it doesn't.
Error
Player.lua:31: bad argument #2 to 'rectangle' (number expected, got nil)
Traceback
[love "callbacks.lua"]:228: in function 'handler'
[C]: in function 'rectangle'
Player.lua:31: in function 'draw'
main.lua:20: in function 'draw'
[love "callbacks.lua"]:168: in function <[love "callbacks.lua"]:144>
[C]: in function 'xpcall'
I triple checked my code and It should work, but it doesn't.