Cj1m
Cj1m

Reputation: 815

Attempt to index global 'p' (a nil value) on line 133

I've been trying to make a main menu for a small project my friend and I are working on. I came across this error on line 133 which is used for player gravity (my friend coded that part). Hear is the code, help would be appreciated:

I couldn't get the code block to work so put it on this URL

http://pastebin.com/ue09X0Bi

P.S very sorry i couldn't get the code block to work.

Upvotes: 1

Views: 4518

Answers (1)

prapin
prapin

Reputation: 6858

The global variable p is used throughout the code but is not assigned anywhere, so its value is logically nil.

Note: it is unusual and not recommendable to have a global variable with a such short name.

EDIT: from the new link you provide in the comment, p is set inside function loadgeneral contained in player.lua. This means that loadgeneral is not called, although it is present at line 19 in function love.load of your script. This is probably normal, since gamestate is there set to "menu" and you immediately compare that variable to "playing", which will always yield false!

Upvotes: 2

Related Questions