The issue is when it fires the event, it only works twice and then it stops working. For example, I will click on it and it’ll combine the ammo with the other mag, and then I’ll click on the other mag and it’ll work again. Then it’ll stop working after that.
Client:
elseif string.find(v.Name, "9mm") then
if v:FindFirstChild("Ammo") then
CombineEvent:FireServer("9MM", v.Ammo)
end
Server:
CombineEvent.OnServerEvent:Connect(function(Player, Action, Ammo)
pcall(function()
if Action == "9MM" then
local Found = false
local UpdatingDeb = false
local ClipSize = 24
if Ammo.Value > 0 and not Ammo.Parent:FindFirstChild("Updating") then
if not Found then
local Updating = Instance.new("BoolValue", Ammo.Parent)
Updating.Name = "Updating"
UpdatingDeb = true
--
for _,v in pairs(Player.Inventory:GetChildren()) do
if v:IsA("Tool") then
if string.find(v.Name, "9mm") then
if v.Ammo.Value < 24 and not v:FindFirstChild("Updating") then
Found = true
print("start again")
repeat wait()
print("start again 2")
if Found and UpdatingDeb then
print("start again 3")
v.Ammo.Value = v.Ammo.Value + 1
wait(0.1)
Ammo.Value = Ammo.Value - 1
end
until v.Ammo.Value >= 24 or Found == false or UpdatingDeb == false or (Ammo.Value <= 0)
print("stop")
Found = false
Updating:Destroy()
UpdatingDeb = false
end
end
end
end
end
end
end
end)
end)