Upgrade=function(Player, Ammo, Damage)
if Player and Ammo and Damage then
local BP,SG,BPGUN,SGGUN=Player:findFirstChild("Backpack"),Player:findFirstChild("StarterGear"),BP:findFirstChild("Gun"),SG:findFirstChild("Gun")
repeat wait(.15) until BP and SG and BPGUN and SGGUN
BPGUN["Stats"]["Ammo"].Value=Ammo
SGGUN["Stats"]["Ammo"].Value=Ammo
BPGUN["Stats"]["Damage"].Value=Damage
SGGUN["Stats"]["Damage"].Value=Damage
end
end
That's just the snippet of code that's erroring. It goes with an armory system with an onTouched function. Whenever I touch the brick, it's supposed to find my Backpack and StarterGear, but so far all I've gotten in the Output is Workspace.ArmoryControl:3: attempt to index global 'BP' (a nil value)
Why is it saying that? I've looked BP over and I can't seem to find why it can't find BP. How would I be able to fix it?
Thank you!

1 comment
It is, BP=Player:findFirstChild("Backpack")