local S=10 local w=1 return function(J,Z,u)local a=Z.CFrame local l=CFrame.new(J.Position,a.Position)local x=Ray.new(l.Position,l.LookVector*500)local K,v=workspace:FindPartOnRay(x,u)local H=(v-a.Position).magnitude local O=(J.LookVector-l.LookVector).magnitude if K and((K==Z or H<S)and O<w)then return true else return false end end
--[[
	Draws a ray between CFrame towards part. If the ray is close to the part (as defined by the discrepencies below), returns true - else returns false.
]]
local MAX_PERIPHERAL_SIGHT = 10
local MAX_SIGHT_RANGE = 1

return function(originCFrame, targetPart, ignoreInstance)
	local targetPartCFrame = targetPart.CFrame

	local pointedCFrame = CFrame.new(originCFrame.Position, targetPartCFrame.Position)

	local ray = Ray.new(pointedCFrame.Position, pointedCFrame.LookVector * 500)

	local hitPart, hitPosition = workspace:FindPartOnRay(ray, ignoreInstance)

	local discrepency = (hitPosition - targetPartCFrame.Position).magnitude
	local range = (originCFrame.LookVector - pointedCFrame.LookVector).magnitude

	if hitPart and (hitPart == targetPart or discrepency < MAX_PERIPHERAL_SIGHT) and range < MAX_SIGHT_RANGE then
		return true
	else
		return false
	end
end
