function FindToolInHand()if players.LocalPlayer.Character and(players.LocalPlayer.Character:FindFirstChild("\072\117\109\097\110\111\105\100")and players.LocalPlayer.Character:FindFirstChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116"))then return players.LocalPlayer.Character:FindFirstChildOfClass("\084\111\111\108")end end function Attack()local W=FindToolInHand()if W and attackCooldown==false then if(require(itemFunctions))[W.ItemType.Value]then attackCooldown=true;(require(itemFunctions))[W.ItemType.Value](W)attackCooldown=false else warn("\084\114\105\101\100 \116\111 \117\115\101 \119\101\097\112\111\110 \097\116\116\097\099\107 \""..(W.ItemType.Value..("\" \098\117\116 \102\097\105\108\101\100 \116\111 \102\105\110\100 \097 \109\097\116\099\104\105\110\103 \102\117\110\099\116\105\111\110 \105\110 "..itemFunctions:GetFullName())))end end end function StrongAttack()local W=FindToolInHand()if W and(strongAttackCooldown==false and attackCooldown==false)then if(require(weaponStrongAttacks))[W.ItemType.Value]then strongAttackCooldown=true;(require(weaponStrongAttacks))[W.ItemType.Value](W)strongAttackCooldown=false else warn("\084\114\105\101\100 \116\111 \117\115\101 \119\101\097\112\111\110 \115\116\114\111\110\103 \097\116\116\097\099\107 \""..(W.ItemType.Value..("\" \098\117\116 \102\097\105\108\101\100 \116\111 \102\105\110\100 \097 \109\097\116\099\104\105\110\103 \102\117\110\099\116\105\111\110 \105\110 "..weaponStrongAttacks:GetFullName())))end end end mouse.Button1Down:Connect(function()if(game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")).KeyboardEnabled==false then wait()local W=Vector2.new(mouse.X,mouse.Y)wait(.25)if math.abs(mouse.X-W.X)>25 or math.abs(mouse.Y-W.Y)>25 then return end end Attack()end)mouse.Button2Down:Connect(function()rightMouseDown=true wait(.15)if rightMouseDown==false then StrongAttack()end end)mouse.Button2Up:Connect(function()rightMouseDown=false end);(game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")).TouchLongPress:Connect(StrongAttack);(game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")).InputBegan:Connect(function(W)if W.KeyCode==Enum.KeyCode.ButtonL2 then StrongAttack()end end)
-- Item usage system
function FindToolInHand()
	if
		players.LocalPlayer.Character
		and players.LocalPlayer.Character:FindFirstChild("Humanoid")
		and players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart")
	then
		return players.LocalPlayer.Character:FindFirstChildOfClass("Tool")
	end
end

function Attack()
	local tool = FindToolInHand()
	if tool and attackCooldown == false then
		if require(itemFunctions)[tool.ItemType.Value] then
			attackCooldown = true
			require(itemFunctions)[tool.ItemType.Value](tool)
			attackCooldown = false
		else
			warn(
				'Tried to use weapon attack "'
					.. tool.ItemType.Value
					.. '" but failed to find a matching function in '
					.. itemFunctions:GetFullName()
			)
		end
	end
end

function StrongAttack()
	local tool = FindToolInHand()
	if tool and strongAttackCooldown == false and attackCooldown == false then
		if require(weaponStrongAttacks)[tool.ItemType.Value] then
			strongAttackCooldown = true
			require(weaponStrongAttacks)[tool.ItemType.Value](tool)
			strongAttackCooldown = false
		else
			warn(
				'Tried to use weapon strong attack "'
					.. tool.ItemType.Value
					.. '" but failed to find a matching function in '
					.. weaponStrongAttacks:GetFullName()
			)
		end
	end
end

mouse.Button1Down:Connect(function() -- Left click attack
	if game:GetService("UserInputService").KeyboardEnabled == false then -- Player is probably on mobile
		wait() -- Mobile mouse position takes a frame to update for some reason
		local lastMousePosition = Vector2.new(mouse.X, mouse.Y)
		wait(0.25)
		if math.abs(mouse.X - lastMousePosition.X) > 25 or math.abs(mouse.Y - lastMousePosition.Y) > 25 then -- Return if the touch position didn't stay in relatively the same place
			return
		end
	end
	Attack()
end)

mouse.Button2Down:Connect(function() -- Right click attack
	rightMouseDown = true
	wait(0.15)
	if rightMouseDown == false then -- People use the right mouse button to move the camera, so we need to get hacky to detect a click
		StrongAttack()
	end
end)

mouse.Button2Up:Connect(function()
	rightMouseDown = false
end)

game:GetService("UserInputService").TouchLongPress:Connect(StrongAttack) -- Mobile strong attack
game:GetService("UserInputService").InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.ButtonL2 then
		StrongAttack()
	end
end)
