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

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
