Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

'If' statements that occur if nil/false?

Asked by 10 years ago

I'm trying to make a script that gives ammo only if the gun is in the backpack (which of course makes sense). However, the script will not continue, because it says the weapon is not a valid member of the backpack (which it isn't, but that's what I'm going for). The script is under an Image Button under a ScreenGUI in the PlayerGUI.

if Player.Backpack.M37 == nil then
        --irrelevant code

elseif Player.Backpack.M37 ~= nil then
        --irrelevant code

--If you need more of the script added then just comment and I will do so

Output simply says 'M37 is not a valid member of Backpack', then disconnects the event at line 8, which is the if Player.Backpack.M37 == nil then line. Any help is greatly appreciated, thank you in advance :)

Answer this question