local Y=script.Parent local Q=Y.Ammo local J=Q.Value local p local H local V function onChanged(Y)if Y=="\086\097\108\117\101"or Y==Q.Value then if H~=nil and V~=nil then if Q.Value>=1 then V.Text=""..(script.Parent.Ammo.Value..("\124"..(script.Parent.StoredAmmo.Value.."")))elseif math.floor(Q.Value)==0 then V.Text=""..(script.Parent.Ammo.Value..("\124"..(script.Parent.StoredAmmo.Value.."")))elseif Q.Value<0 then for Y=0,1,.015 do local Q=math.floor(Y*J+.5)V.Text=""..(script.Parent.Ammo.Value..("\124"..(script.Parent.StoredAmmo.Value.."")))wait()end end end end end function on2Changed()if H~=nil and V~=nil then V.Text=""..(script.Parent.Ammo.Value..("\124"..(script.Parent.StoredAmmo.Value.."")))wait()end end function setUpGui()if p==nil or p:findFirstChild("\080\108\097\121\101\114\071\117\105")==nil then return end H=Instance.new("\083\099\114\101\101\110\071\117\105")V=Instance.new("\084\101\120\116\076\097\098\101\108")H.Name="\068\069\068\105\115\112\108\097\121"H.Parent=p.PlayerGui V.BackgroundColor3=(BrickColor.Black()).Color V.BackgroundTransparency=1 V.BorderColor3=(BrickColor.White()).Color V.BorderSizePixel=0 V.Name="\065\109\109\111"V.Parent=H V.Position=UDim2.new(.85,0,.825,0)V.Size=UDim2.new(0,128,0,64)V.FontSize="\083\105\122\101\049\056"V.Text=""..(script.Parent.Ammo.Value..("\124"..(script.Parent.StoredAmmo.Value.."")))V.TextColor3=(BrickColor.White()).Color end function onEquippedLocal(Y)p=game.Players.LocalPlayer setUpGui()end function onUnequippedLocal(Y)if H then H:remove()end H=nil V=nil p=nil end Y.Equipped:connect(onEquippedLocal)Y.Unequipped:connect(onUnequippedLocal)Q.Changed:connect(onChanged)Y.StoredAmmo.Changed:connect(on2Changed)


local Tool = script.Parent
local Ammo = Tool.Ammo
local MaxAmmo = Ammo.Value

local vPlayer
local Gui
local Text

function onChanged(value)
	if value == "Value" or value == Ammo.Value then
		if Gui ~= nil and Text ~= nil then
			if Ammo.Value >= 1 then
				Text.Text = ""..script.Parent.Ammo.Value.."|"..script.Parent.StoredAmmo.Value..""
			elseif math.floor(Ammo.Value) == 0 then
				Text.Text = ""..script.Parent.Ammo.Value.."|"..script.Parent.StoredAmmo.Value..""
			elseif Ammo.Value < 0 then
				for i = 0, 1, 0.03 / 2 do
					local Num = math.floor(i * MaxAmmo + 0.5)

					Text.Text = ""..script.Parent.Ammo.Value.."|"..script.Parent.StoredAmmo.Value..""
					wait()
				end
			end
		end
	end
end

function on2Changed()
	if Gui ~= nil and Text ~= nil then

		Text.Text = ""..script.Parent.Ammo.Value.."|"..script.Parent.StoredAmmo.Value..""
		wait()
	end
end

function setUpGui()
	if vPlayer == nil or vPlayer:findFirstChild("PlayerGui") == nil then
		return
	end

	Gui = Instance.new("ScreenGui")
	Text = Instance.new("TextLabel")

	Gui.Name = "DEDisplay"
	Gui.Parent = vPlayer.PlayerGui

	Text.BackgroundColor3 = BrickColor.Black().Color
   Text.BackgroundTransparency = 1
	Text.BorderColor3 = BrickColor.White().Color
   Text.BorderSizePixel = 0
	Text.Name = "Ammo"
	Text.Parent = Gui
	Text.Position = UDim2.new(0.85, 0, 0.825, 0)
	Text.Size = UDim2.new(0, 128, 0, 64)
   Text.FontSize = "Size18"
	Text.Text = ""..script.Parent.Ammo.Value.."|"..script.Parent.StoredAmmo.Value..""
	Text.TextColor3 = BrickColor.White().Color
end

function onEquippedLocal(mouse)
	vPlayer = game.Players.LocalPlayer

	setUpGui()
end

function onUnequippedLocal(mouse)
	if Gui then
		Gui:remove()
	end

	Gui = nil
	Text = nil
	vPlayer = nil
end

Tool.Equipped:connect(onEquippedLocal)
Tool.Unequipped:connect(onUnequippedLocal)

Ammo.Changed:connect(onChanged)
Tool.StoredAmmo.Changed:connect(on2Changed)
