local B=(game:GetService("\080\108\097\121\101\114\115")).LocalPlayer;(game:GetService("\083\116\097\114\116\101\114\071\117\105")):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false)local f=(game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")).hotbarTemplate local e=game:GetService("\084\119\101\101\110\083\101\114\118\105\099\101")local L=B.Character or B.CharacterAdded:Wait()function getToolAmt()local f=0 local e,N,m=pairs(L:GetChildren())while true do local B,L=e(N,m)if B then else break end m=B if L:IsA("\084\111\111\108")then f=f+1 end end local z,x,Q=pairs(B.Backpack:GetChildren())while true do local B,e=z(x,Q)if B then else break end Q=B if e:IsA("\084\111\111\108")then f=f+1 end end return f end local N={[Enum.KeyCode.One]=Enum.KeyCode.One;[Enum.KeyCode.Two]=Enum.KeyCode.Two;[Enum.KeyCode.Three]=Enum.KeyCode.Three;[Enum.KeyCode.Four]=Enum.KeyCode.Four,[Enum.KeyCode.Five]=Enum.KeyCode.Five;[Enum.KeyCode.Six]=Enum.KeyCode.Six,[Enum.KeyCode.Seven]=Enum.KeyCode.Seven,[Enum.KeyCode.Eight]=Enum.KeyCode.Eight,[Enum.KeyCode.Nine]=Enum.KeyCode.Nine;[Enum.KeyCode.Zero]=Enum.KeyCode.Zero}local m=B.PlayerGui.MainUI.Hotbar if not m then local f=script.Hotbar:Clone()f=B.PlayerGui.MainUI m=f end local z={"\079\110\101";"\084\119\111","\084\104\114\101\101";"\070\111\117\114";"\070\105\118\101","\083\105\120","\083\101\118\101\110","\069\105\103\104\116","\078\105\110\101","\090\101\114\111"};(game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")).InputBegan:Connect(function(f,e)if e then return end if N[f.KeyCode]then for e,L in pairs(m:GetChildren())do if L:IsA("\084\101\120\116\066\117\116\116\111\110")and f.KeyCode==Enum.KeyCode[z[tonumber(L.SlotNum.Text)]]then script.Parent.EquipTool:FireServer(B.Backpack:FindFirstChild(L.Name)or game.Players.LocalPlayer.Character:FindFirstChild(L.Name))end end end end)function addToolToHotbar(e)local L=f:Clone()L.Name=e.Name L.Parent=m L.Tool.Image=e.TextureId or"\114\098\120\097\115\115\101\116\105\100\058\047\047\048"L.SlotNum.Text=tostring(getToolAmt())L.MouseButton1Click:Connect(function()script.Parent.EquipTool:FireServer(B.Backpack:FindFirstChild(e.Name)or game.Players.LocalPlayer.Character:FindFirstChild(e.Name))end)m.Size=m.Size+UDim2.new(.25,0,0,0)end for f,L in pairs(B.Backpack:GetChildren())do if L:IsA("\084\111\111\108")then if not m:FindFirstChild(L.Name)then addToolToHotbar(L)else local f=0 local N={}for B,e in pairs(B.Backpack:GetChildren())do if e.Name==L.Name then f=f+1 table.insert(N,e)end end for B,e in pairs((game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")).PlayerStorage:GetChildren())do if e.Name==L.Name then f=f+1 end end if f>1 then m[L.Name].DurabilityNumber.Visible=true m[L.Name].DurabilityNumber.Text="\120"..tostring(f)wait(0)N[1].Parent=(game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")).PlayerStorage else m[L.Name].UIStroke.Transparency=.7;(e:Create(m[L.Name],TweenInfo.new(.1,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut),{Size=UDim2.new(.8,0,.8,0)})):Play()end end end end B.Backpack.ChildAdded:Connect(function(f)if f:IsA("\084\111\111\108")then if not m:FindFirstChild(f.Name)then addToolToHotbar(f)return end local L=0 local N={}for B,e in pairs(B.Backpack:GetChildren())do if e.Name==f.Name then L=L+1 table.insert(N,e)end end for B,e in pairs((game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")).PlayerStorage:GetChildren())do if e.Name==f.Name then L=L+1 end end if L>1 then m[f.Name].DurabilityNumber.Visible=true m[f.Name].DurabilityNumber.Text="\120"..tostring(L)wait(0)N[1].Parent=(game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")).PlayerStorage return else m[f.Name].UIStroke.Transparency=.7;(e:Create(m[f.Name],TweenInfo.new(.1,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut),{Size=UDim2.new(.8,0,.8,0)})):Play()end end end)B.Character.ChildAdded:Connect(function(B)if B:IsA("\084\111\111\108")then if not m:FindFirstChild(B.Name)then addToolToHotbar(B)end local f=m[B.Name]f.UIStroke.Transparency=0;(e:Create(f,TweenInfo.new(.1,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut),{Size=UDim2.new(1,0,1,0)})):Play()end end)B.Character.ChildRemoved:Connect(function(f)if f:IsA("\084\111\111\108")and(f.Parent~=B.Backpack and(f.Parent~=(game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")).PlayerStorage and m:FindFirstChild(f.Name)))then local e=tonumber(string.sub(m[f.Name].DurabilityNumber.Text,2,2))if m[f.Name].DurabilityNumber.Visible and e>1 then m[f.Name].DurabilityNumber.Text="\120"..tostring(e-1)if m[f.Name].DurabilityNumber.Text=="\120\049"then m[f.Name].DurabilityNumber.Visible=false end;((game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")).PlayerStorage:FindFirstChild(f.Name)).Parent=B.Character return end m[f.Name]:Destroy()m.Size=m.Size-UDim2.new(.25,0,0,0)local L=1 for B,f in pairs(m:GetChildren())do if f:IsA("\084\101\120\116\066\117\116\116\111\110")then f.SlotNum.Text=tostring(L)L=L+1 end end end end)


local l__LocalPlayer__1 = game:GetService("Players").LocalPlayer;
game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false);
local l__hotbarTemplate__2 = game:GetService("ReplicatedStorage").hotbarTemplate;
local l__TweenService__3 = game:GetService("TweenService");
local u1 = l__LocalPlayer__1.Character or l__LocalPlayer__1.CharacterAdded:Wait();
function getToolAmt()
	local v4 = 0;
	local v5, v6, v7 = pairs(u1:GetChildren());
	while true do
		local v8, v9 = v5(v6, v7);
		if v8 then

		else
			break;
		end;
		v7 = v8;
		if v9:IsA("Tool") then
			v4 = v4 + 1;
		end;	
	end;
	local v10, v11, v12 = pairs(l__LocalPlayer__1.Backpack:GetChildren());
	while true do
		local v13, v14 = v10(v11, v12);
		if v13 then

		else
			break;
		end;
		v12 = v13;
		if v14:IsA("Tool") then
			v4 = v4 + 1;
		end;	
	end;
	return v4;
end;
local u2 = {
	[Enum.KeyCode.One] = Enum.KeyCode.One, 
	[Enum.KeyCode.Two] = Enum.KeyCode.Two, 
	[Enum.KeyCode.Three] = Enum.KeyCode.Three, 
	[Enum.KeyCode.Four] = Enum.KeyCode.Four, 
	[Enum.KeyCode.Five] = Enum.KeyCode.Five, 
	[Enum.KeyCode.Six] = Enum.KeyCode.Six, 
	[Enum.KeyCode.Seven] = Enum.KeyCode.Seven, 
	[Enum.KeyCode.Eight] = Enum.KeyCode.Eight, 
	[Enum.KeyCode.Nine] = Enum.KeyCode.Nine, 
	[Enum.KeyCode.Zero] = Enum.KeyCode.Zero
};
local l__Hotbar__3 = l__LocalPlayer__1.PlayerGui.MainUI.Hotbar;
if not l__Hotbar__3 then
	local hotbar = script.Hotbar:Clone()
	hotbar	= l__LocalPlayer__1.PlayerGui.MainUI
	l__Hotbar__3 = hotbar
end
local u4 = { "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Zero" };
game:GetService("UserInputService").InputBegan:Connect(function(p1, p2)
	if p2 then
		return;
	end;
	if u2[p1.KeyCode] then
		for v15, v16 in pairs(l__Hotbar__3:GetChildren()) do
			if v16:IsA("TextButton") and p1.KeyCode == Enum.KeyCode[u4[tonumber(v16.SlotNum.Text)]] then
				script.Parent.EquipTool:FireServer(l__LocalPlayer__1.Backpack:FindFirstChild(v16.Name) or  game.Players.LocalPlayer.Character:FindFirstChild(v16.Name));
			end;
		end;
	end;
end);
function addToolToHotbar(p3)
	local v17 = l__hotbarTemplate__2:Clone();
	v17.Name = p3.Name;
	v17.Parent = l__Hotbar__3;
	v17.Tool.Image = p3.TextureId or "rbxassetid://0";
	v17.SlotNum.Text = tostring(getToolAmt());
	v17.MouseButton1Click:Connect(function()
		script.Parent.EquipTool:FireServer(l__LocalPlayer__1.Backpack:FindFirstChild(p3.Name) or game.Players.LocalPlayer.Character:FindFirstChild(p3.Name));
	end);
	l__Hotbar__3.Size = l__Hotbar__3.Size + UDim2.new(0.25, 0, 0, 0);
end;
for v18, v19 in pairs(l__LocalPlayer__1.Backpack:GetChildren()) do
	if v19:IsA("Tool") then
		if not l__Hotbar__3:FindFirstChild(v19.Name) then
			addToolToHotbar(v19);
		else
			local v20 = 0;
			local v21 = {};
			for v22, v23 in pairs(l__LocalPlayer__1.Backpack:GetChildren()) do
				if v23.Name == v19.Name then
					v20 = v20 + 1;
					table.insert(v21, v23);
				end;
			end;
			for v24, v25 in pairs(game:GetService("ReplicatedStorage").PlayerStorage:GetChildren()) do
				if v25.Name == v19.Name then
					v20 = v20 + 1;
				end;
			end;
			if v20 > 1 then
				l__Hotbar__3[v19.Name].DurabilityNumber.Visible = true;
				l__Hotbar__3[v19.Name].DurabilityNumber.Text = "x" .. tostring(v20);
				wait(0);
				v21[1].Parent = game:GetService("ReplicatedStorage").PlayerStorage;
			else
				l__Hotbar__3[v19.Name].UIStroke.Transparency = 0.7;
				l__TweenService__3:Create(l__Hotbar__3[v19.Name], TweenInfo.new(0.1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {
					Size = UDim2.new(0.8, 0, 0.8, 0)
				}):Play();
			end;
		end;
	end;
end;
l__LocalPlayer__1.Backpack.ChildAdded:Connect(function(p4)
	if p4:IsA("Tool") then
		if not l__Hotbar__3:FindFirstChild(p4.Name) then
			addToolToHotbar(p4);
			return;
		end;
		local v26 = 0;
		local v27 = {};
		for v28, v29 in pairs(l__LocalPlayer__1.Backpack:GetChildren()) do
			if v29.Name == p4.Name then
				v26 = v26 + 1;
				table.insert(v27, v29);
			end;
		end;
		for v30, v31 in pairs(game:GetService("ReplicatedStorage").PlayerStorage:GetChildren()) do
			if v31.Name == p4.Name then
				v26 = v26 + 1;
			end;
		end;
		if v26 > 1 then
			l__Hotbar__3[p4.Name].DurabilityNumber.Visible = true;
			l__Hotbar__3[p4.Name].DurabilityNumber.Text = "x" .. tostring(v26);
			wait(0);
			v27[1].Parent = game:GetService("ReplicatedStorage").PlayerStorage;
			return;
		else
			l__Hotbar__3[p4.Name].UIStroke.Transparency = 0.7;
			l__TweenService__3:Create(l__Hotbar__3[p4.Name], TweenInfo.new(0.1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {
				Size = UDim2.new(0.8, 0, 0.8, 0)
			}):Play();
		end;
	end;
end);
l__LocalPlayer__1.Character.ChildAdded:Connect(function(p5)
	if p5:IsA("Tool") then
		if not l__Hotbar__3:FindFirstChild(p5.Name) then
			addToolToHotbar(p5);
		end;
		local v32 = l__Hotbar__3[p5.Name];
		v32.UIStroke.Transparency = 0;
		l__TweenService__3:Create(v32, TweenInfo.new(0.1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {
			Size = UDim2.new(1, 0, 1, 0)
		}):Play();
	end;
end);
l__LocalPlayer__1.Character.ChildRemoved:Connect(function(p6)
	if p6:IsA("Tool") and p6.Parent ~= l__LocalPlayer__1.Backpack and p6.Parent ~= game:GetService("ReplicatedStorage").PlayerStorage and l__Hotbar__3:FindFirstChild(p6.Name) then
		local v33 = tonumber(string.sub(l__Hotbar__3[p6.Name].DurabilityNumber.Text, 2, 2));
		if l__Hotbar__3[p6.Name].DurabilityNumber.Visible and v33 > 1 then
			l__Hotbar__3[p6.Name].DurabilityNumber.Text = "x" .. tostring(v33 - 1);
			if l__Hotbar__3[p6.Name].DurabilityNumber.Text == "x1" then
				l__Hotbar__3[p6.Name].DurabilityNumber.Visible = false;
			end;
			game:GetService("ReplicatedStorage").PlayerStorage:FindFirstChild(p6.Name).Parent = l__LocalPlayer__1.Character;
			return;
		end;
		l__Hotbar__3[p6.Name]:Destroy();
		l__Hotbar__3.Size = l__Hotbar__3.Size - UDim2.new(0.25, 0, 0, 0);
		local v34 = 1;
		for v35, v36 in pairs(l__Hotbar__3:GetChildren()) do
			if v36:IsA("TextButton") then
				v36.SlotNum.Text = tostring(v34);
				v34 = v34 + 1;
			end;
		end;
	end;
end);
