The code below makes it so that every time the cannon is fired, the number value goes down by one and once it reaches 0, the cannon has to be resupplied. The problem is that every time the function is called, nothing happens to the number value.
repeat wait() until script.Parent.Parent.Vehicle.Value~=nil
db=false
held=false
v=script.Parent.Parent.Vehicle
f=script.Parent
missile=script.Parent.HE
f=script.Parent
bin=script.Parent
function fireguns()
v1=v.Value.Gun1Bullet:clone()
vel=Instance.new("BodyVelocity")
vel.Parent=v1
v1.Velocity=v1.CFrame.lookVector*500
v1.BodyVelocity.maxForce=Vector3.new(4000, 0, 4000)
vel.velocity=v1.Velocity
v1.CanCollide=true
v1.Transparency=0
v1.Damage.Disabled=false
v1.Parent=workspace
end
function launchmissile()
v.Value.Effect.PointLight.Enabled = true
v.Value.Effect.Smoke.Enabled = true
v.Value.Missile.Fire.Enabled = true
v.Value.Effect.Light.Enabled = true
v.Value.Effect.Fire:Play()
v.Value.Effect.Transparency = .5
v.Value.WER2.Value.C0 = v.Value.WER2.Value.C0 - Vector3.new(0,0, .5)
v1=v.Value.Missile:clone()
v1.CFrame = v.Value.Missile.CFrame * CFrame.new(0, 0, -5)
vel=Instance.new("BodyVelocity")
vel.Parent=v1
v1.Velocity=v1.CFrame.lookVector*500
v1.BodyVelocity.maxForce=Vector3.new(4000, 0, 4000)
vel.velocity=v1.Velocity
v1.CanCollide=true
v1.Transparency= 0
v1.Heat.Disabled=false
v1.Parent=workspace
wait(.001)
v.Value.WER2.Value.C0 = v.Value.WER2.Value.C0 + Vector3.new(0,0, .1)
v.Value.Effect.Transparency = .6
wait(.001)
v.Value.WER2.Value.C0 = v.Value.WER2.Value.C0 + Vector3.new(0,0, .1)
v.Value.Effect.Transparency = .7
wait(.001)
v.Value.WER2.Value.C0 = v.Value.WER2.Value.C0 + Vector3.new(0,0, .1)
v.Value.Effect.Transparency = .8
wait(.001)
v.Value.WER2.Value.C0 = v.Value.WER2.Value.C0 + Vector3.new(0,0, .1)
v.Value.Effect.Transparency = .9
wait(.001)
v.Value.WER2.Value.C0 = v.Value.WER2.Value.C0 + Vector3.new(0,0, .1)
v.Value.Effect.Transparency = 1
v.Value.Effect.PointLight.Enabled = false
v.Value.Effect.Smoke.Enabled = false
v.Value.Missile.Fire.Enabled = false
v.Value.Effect.Light.Enabled = false
wait(.001)
end
function missileclick()
local ammo = bin.Munitions
ammo.Value = ammo.Value-1
f.Visible = false
print("click missile")
if db==true then return end
db=true
missile.Text="Reloading"
launchmissile()
v.Value.Effect.Reload:Play()
wait(4)
missile.Text="Fire HE"
v.Value.Effect.Reload:Stop()
db=false
f.Visible = true
end
function gunsdown()
held=true
while held==true do
fireguns()
wait()
end
end
function gunsup()
held=false
print("up")
end
missile.MouseButton1Click:connect(missileclick)
--sabot.MouseButton1Click:connect(sabotclick)
guns.MouseButton1Down:connect(gunsdown)
guns.MouseButton1Up:connect(gunsup)

6 comments
Is it really a NumberValue, not string? Any printed errors? Can you give us your whole script, you're not defining variables in this. Is the hierarchy correct?
the "bin" mentioned is just the scripts parent which is the GUI the number value is in the same gui.
Can we still see the entire code? We want to see when missleclick() is called, and we want to see the hierarchy for ourselves. Explaining hierarchy is like saying a complicated math expression out loud; once too many quantities get involved, it becomes confusing.
try and change the 'bin.Munitions' thing, and remove all the variables and make it script.whatever
@ConnorXV The variables don't cause any errors. Also, are db and f created beforehand?
Here is the full code