local function t(t)if Enabled and(t and t.Parent)then local o=false local e=game.Players:GetPlayerFromCharacter(t.Parent)if e then for t,N in pairs(GunToRefillAmmo)do local r=e.Backpack:FindFirstChild(N)or e.Character:FindFirstChild(N)if r then local t=r:FindFirstChild("\071\117\110\083\099\114\105\112\116\095\083\101\114\118\101\114")local N=r:FindFirstChild("\083\101\116\116\105\110\103")if t and N then local r=require(N)if t.Ammo.Value<r.MaxAmmo and r.LimitedAmmoEnabled then Enabled=false o=true local N=(Ammo==math.huge or t.Ammo.Value+Ammo>=r.Ammo)and r.Ammo or t.Ammo.Value+Ammo t.Ammo.Value=N t.ChangeMagAndAmmo:FireClient(e,r.AmmoPerMag,N)end end end end end if o then AmmoBox:Destroy()end end end AmmoBox.Touched:connect(t)


local function Enablerx2(Hit)
	if Enabled and Hit and Hit.Parent then
		local AmmoRefilled = false
		local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
		if Player then
			for _, GunName in pairs(GunToRefillAmmo) do
				local Gun = Player.Backpack:FindFirstChild(GunName) or Player.Character:FindFirstChild(GunName)
				if Gun then
					local GunScript = Gun:FindFirstChild("GunScript_Server")
					local Module = Gun:FindFirstChild("Setting")
					if GunScript and Module then
						local Module = require(Module)
						if GunScript.Ammo.Value < Module.MaxAmmo and Module.LimitedAmmoEnabled then
							Enabled = false
							AmmoRefilled = true
							local ChangedAmmo = (Ammo == math.huge or GunScript.Ammo.Value+Ammo >= Module.Ammo) and Module.Ammo or (GunScript.Ammo.Value + Ammo)
							GunScript.Ammo.Value = ChangedAmmo
							GunScript.ChangeMagAndAmmo:FireClient(Player,Module.AmmoPerMag,ChangedAmmo)
						end
					end
				end
			end
		end
		if AmmoRefilled then AmmoBox:Destroy() end
	end
end
AmmoBox.Touched:connect(Enablerx2)
