local m=Tool:WaitForChild("\076\105\098\114\097\114\105\101\115")local o=require(m:WaitForChild("\083\117\112\112\111\114\116\076\105\098\114\097\114\121"))local c=require(m:WaitForChild("\083\105\103\110\097\108"))local h=require(m:WaitForChild("\077\097\107\101"))local n=require(m:WaitForChild("\073\110\115\116\097\110\099\101\080\111\111\108"))TargetingModule={}TargetingModule.TargetingMode="\083\099\111\112\101\100"TargetingModule.TargetingModeChanged=c.new()TargetingModule.Scope=Workspace TargetingModule.IsScopeLocked=true TargetingModule.TargetChanged=c.new()TargetingModule.ScopeChanged=c.new()TargetingModule.ScopeTargetChanged=c.new()TargetingModule.ScopeLockChanged=c.new()function TargetingModule.EnableTargeting(m)local c=GetCore()local h=c.Connections Mouse=c.Mouse h.Targeting=Mouse.Move:Connect(function()m:UpdateTarget(m.Scope)end)h.Selecting=Mouse.Button1Up:Connect(m.SelectTarget)h.SiblingSelecting=o.AddUserInputListener("\066\101\103\097\110","\077\111\117\115\101\066\117\116\116\111\110\051",true,function()m.SelectSiblings(Mouse.Target,not Selection.Multiselecting)end)h.RectSelectionStarted=Mouse.Button1Down:Connect(m.StartRectangleSelecting)h.RectSelectionFinished=o.AddUserInputListener("\069\110\100\101\100","\077\111\117\115\101\066\117\116\116\111\110\049",true,m.FinishRectangleSelecting)h.HideTargetBoxOnDisable=c.Disabling:Connect(m.HighlightTarget)h.CancelSelectionOnDisable=c.Disabling:Connect(m.CancelRectangleSelecting)m:EnableScopeSelection()m:EnableScopeAutoReset()m:BindTargetingModeHotkeys()end function TargetingModule.SetScope(o,m)if o.Scope~=m then o.Scope=m o.ScopeChanged:Fire(m)end end local function p(m)return m:IsA("\077\111\100\101\108")or m:IsA("\066\097\115\101\080\097\114\116")end local function i(m)return m:IsA("\077\111\100\101\108")or m:IsA("\066\097\115\101\080\097\114\116")or m:IsA("\084\111\111\108")or m:IsA("\065\099\099\101\115\115\111\114\121")or m:IsA("\065\099\099\111\117\116\114\101\109\101\110\116")end
-- Libraries
local Libraries = Tool:WaitForChild("Libraries")
local Support = require(Libraries:WaitForChild("SupportLibrary"))
local Signal = require(Libraries:WaitForChild("Signal"))
local Make = require(Libraries:WaitForChild("Make"))
local InstancePool = require(Libraries:WaitForChild("InstancePool"))

TargetingModule = {}
TargetingModule.TargetingMode = "Scoped"
TargetingModule.TargetingModeChanged = Signal.new()
TargetingModule.Scope = Workspace
TargetingModule.IsScopeLocked = true
TargetingModule.TargetChanged = Signal.new()
TargetingModule.ScopeChanged = Signal.new()
TargetingModule.ScopeTargetChanged = Signal.new()
TargetingModule.ScopeLockChanged = Signal.new()

function TargetingModule:EnableTargeting()
	-- 	Begin targeting parts from the mouse

	-- Get core API
	local Core = GetCore()
	local Connections = Core.Connections

	-- Create reference to mouse
	Mouse = Core.Mouse

	-- Listen for target changes
	Connections.Targeting = Mouse.Move:Connect(function()
		self:UpdateTarget(self.Scope)
	end)

	-- Listen for target clicks
	Connections.Selecting = Mouse.Button1Up:Connect(self.SelectTarget)

	-- Listen for sibling selection middle clicks
	Connections.SiblingSelecting = Support.AddUserInputListener("Began", "MouseButton3", true, function()
		self.SelectSiblings(Mouse.Target, not Selection.Multiselecting)
	end)

	-- Listen for 2D selection
	Connections.RectSelectionStarted = Mouse.Button1Down:Connect(self.StartRectangleSelecting)
	Connections.RectSelectionFinished =
		Support.AddUserInputListener("Ended", "MouseButton1", true, self.FinishRectangleSelecting)

	-- Hide target box when tool is unequipped
	Connections.HideTargetBoxOnDisable = Core.Disabling:Connect(self.HighlightTarget)

	-- Cancel any ongoing selection when tool is unequipped
	Connections.CancelSelectionOnDisable = Core.Disabling:Connect(self.CancelRectangleSelecting)

	-- Enable scope selection
	self:EnableScopeSelection()

	-- Enable automatic scope resetting
	self:EnableScopeAutoReset()

	-- Enable targeting mode hotkeys
	self:BindTargetingModeHotkeys()
end

function TargetingModule:SetScope(Scope)
	if self.Scope ~= Scope then
		self.Scope = Scope
		self.ScopeChanged:Fire(Scope)
	end
end

local function IsVisible(Item)
	return Item:IsA("Model") or Item:IsA("BasePart")
end

local function IsTargetable(Item)
	return Item:IsA("Model")
		or Item:IsA("BasePart")
		or Item:IsA("Tool")
		or Item:IsA("Accessory")
		or Item:IsA("Accoutrement")
end
