So my gun system I have been working on with FastCast is pretty much done, but I’m trying to figure out ammo. I have it to detect when the ammo is 0 but the ammo sometimes go to negatives.
Any help would be appreciated
if script.Parent.Configuration.Ammo.Value <= 0 then
script.Parent.Configuration.Ammo.Value = script.Parent.Configuration.Ammo.Value + 30
CanFire = true
end
end)
while true do
wait()
if script.Parent.Configuration.Ammo.Value <= 0 then
CanFire = false
end
end
local Ammo = script.Parent.Configuration.Ammo.Value
local MinAmmo = script.Parent.Configuration.MinAmmo.Value
Ammo.Changed:Connect(function()
Ammo = math.clamp(MinAmmo, 0, Ammo)
end)```