My M4 should be refilling its ammo by adding 100 rounds into reserve every time I touch a certain block but nothing happens and I receive no errors. I have 'Ammo' and 'StoredAmmo' NumberValues inside the main script of my M4, I would know if I was receiving ammo because I have an ammo GUI that works but no ammo is added.
function onTouched(hit)
local human = hit.Parent:FindFirstChild("Humanoid")
local player = game.Players:FindFirstChild(hit.Parent.Name)
if (human ~= nil) then
local StoredAmmo = human.Parent.M4A1.Gun_Script.StoredAmmo
if (StoredAmmo~=nil) then
StoredAmmo.Value = StoredAmmo.Value + 100
script.Parent:Destroy()
end
end
end
script.Parent.Touched:Connect(onTouched)
Any help is appreciated, not sure how to go about this.

2 comments
Hate to be that guy but those if checks should be debugged and made sure they’re fired.
For debugging i always put print commands in different places to get a better idea where the problem is