lxFirebal69xl Posted February 21, 2015 Share Posted February 21, 2015 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 Quote Link to comment Share on other sites More sharing options...
Rick Posted February 21, 2015 Share Posted February 21, 2015 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. Quote Link to comment Share on other sites More sharing options...
lxFirebal69xl Posted February 21, 2015 Author Share Posted February 21, 2015 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 Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted February 21, 2015 Share Posted February 21, 2015 Put this line: local pickInfo = PickInfo() Above the if self.canLookAround then Quote Link to comment Share on other sites More sharing options...
Rick Posted February 21, 2015 Share Posted February 21, 2015 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. Quote Link to comment Share on other sites More sharing options...
lxFirebal69xl Posted February 21, 2015 Author Share Posted February 21, 2015 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. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted February 21, 2015 Share Posted February 21, 2015 Have you linked in the inventory manager entity? Quote Link to comment Share on other sites More sharing options...
lxFirebal69xl Posted February 21, 2015 Author Share Posted February 21, 2015 Have you linked in the inventory manager entity? Yes, everything is linked correctly. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted February 21, 2015 Share Posted February 21, 2015 Can you show a screenshot of what you have linked in and what scripts are attached to it? Quote Link to comment Share on other sites More sharing options...
lxFirebal69xl Posted February 21, 2015 Author Share Posted February 21, 2015 Here you go Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted February 21, 2015 Share Posted February 21, 2015 I mean for the inventory items. That is where the script is attached. Do all items have the inventory manager linked? Quote Link to comment Share on other sites More sharing options...
lxFirebal69xl Posted February 21, 2015 Author Share Posted February 21, 2015 Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted February 21, 2015 Share Posted February 21, 2015 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. Quote Link to comment Share on other sites More sharing options...
lxFirebal69xl Posted February 21, 2015 Author Share Posted February 21, 2015 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.