-- Decompiled with the Synapse X Luau decompiler.


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);
