Jump to content

lxFirebal69xl
 Share

Recommended Posts

So for the last couple of days I've been trying to make my own FPSPlayer script with the help of some other users. I managed to do everything I wanted but there's one problem. I don't know how to fix this error.

 

Script Error
error in function 'Pick'.
argument #4 is 'nil'; 'value' expected.
Line 465

 

The script is a combination of Aggror's FlowGUI FPSPlayer and my own, that's probably why it doesn't work.

 

 

Any help would be appreciated!

FPSPlayer New.lua

Link to comment
Share on other sites

Does it highlight a line when it fails? Line 465 to me looks like a comment so that's lua being not very helpful in it's error line number. The error must be happening in a call to the Pick() function. It's saying the 4th argument, which to us will be the 3rd because there is a magic lua argument as the 1st that we don't see. So whatever is the 3rd parameter to some pick function that should be getting highlighted on the error, it's saying that value is nil, null, nothing and it should be something.

Link to comment
Share on other sites

Does it highlight a line when it fails? Line 465 to me looks like a comment so that's lua being not very helpful in it's error line number. The error must be happening in a call to the Pick() function. It's saying the 4th argument, which to us will be the 3rd because there is a magic lua argument as the 1st that we don't see. So whatever is the 3rd parameter to some pick function that should be getting highlighted on the error, it's saying that value is nil, null, nothing and it should be something.

 

This is all that it does

post-13811-0-15086700-1424534719_thumb.png

Link to comment
Share on other sites

It's interesting that when I open this up in Notepadd++ that's not line 465 for me. Anyway it's saying that your pickInfo variable doesn't exist. You need to declare it as:

 

local pickInfo = PickInfo()

 

before this.

 

Now you'll look above and see pickInfo being used in other places so why can't it be use here right? Well it's declared local in those other places and anything declared local inside any block (if, loop, etc) will ONLY be visible inside that and nested blocks. Not outside that block.

 

So if you trace updward you'll see pickInfo declared inside the if self.canLookAround then if block (about a 40 lines into that if block). Your current error is inside the if window:KeyHit(Key.E) then if block. Those 2 blocks are at the same level so that pickInfo in the first block is ONLY visible and usable inside that block.

 

This is a variable scope issue and it's important to understand variable scope (where variables can be seen). Ideally, I think this entire function should just declare local pickInfo = PickInfo() as the first line inside of it and then you don't have to worry about all of these other pickInfo declarations.

Link to comment
Share on other sites

Thank you both for the answers, I got the issue fixed.

Now I got another problem (Programming is fun isn't it?), when I try to pick up an item it gives me this error

 

Script Error
attempt to index field 'playerInventoryMgr' (a nil value)
Line 27

 

I guess this one is more towards aggror since he made FlowGUI, this wasn't happening before.

Here's the script if you want to take a look at it.

StorableObject New.lua

 

Thanks for the help once again.

Link to comment
Share on other sites

I can't see anything out of the ordinary. Sometimes the referenced items are not correctly displayed.

 

One thing I want to suggest is emptying the referenced inventory for all items and relink the inventory manager.

Also, I assume the inventory manager item has the inventorymanager script attached?

 

If that doesn't work you can send me the map in pm, and I will have a look tonight.

Link to comment
Share on other sites

I can't see anything out of the ordinary. Sometimes the referenced items are not correctly displayed.

 

One thing I want to suggest is emptying the referenced inventory for all items and relink the inventory manager.

Also, I assume the inventory manager item has the inventorymanager script attached?

 

If that doesn't work you can send me the map in pm, and I will have a look tonight.

 

Did what you said, still doesn't work. I'll be sending you the map in PM

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...