I need help fixing my reloading system that I have made. After I reload, it prints that I do in fact have 30 ammo and that it can start shooting again, but then after one shot it’s out, only after its been reloaded. I have tried fixing it by changing how it works, but it still won’t fix.
Module:
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
script.Parent.Activated:Connect(function()
if script.Parent.Ammo.Value > 0 then
print(script.Parent.Ammo.Value)
script.Parent.FakeMag.Transparency = 0
script.Parent.GunFire:FireServer(mouse.Target.Parent)
else
print("Empty")
script.Disabled = true
script.Parent.FakeMag.Transparency = 1
end
end)
PickUpAmmo:
local player = game.Players.LocalPlayer
script.Parent.Activated:Connect(function()
if script.Parent.Ammo.Value == 0 then
game.ReplicatedStorage.PickUpAmmo.OnClientEvent:Connect(function()
script.Parent.Ammo.Value += 30
script.Parent.Module.Disabled = false
print(script.Parent.Ammo.Value)
end)
end
end)
Shoot:
script.Parent.GunFire.OnServerEvent:Connect(function(plr, target)
script.Parent.Handle["MP5 Fire"]:Play()
script.Parent.Ammo.Value -= 1
target:FindFirstChild("Humanoid").Health = target:FindFirstChild("Humanoid").Health - 10
end)