I am working on a turret that shoots out a beam to the closest enemy in its ‘range’. For this, I want to make a table of all the enemies in range and then pick the closest one to aim at.

My question is, how would I calculate if a certain point is within a cone or not?

I’m not sure if this helps your situation, but I have a function that gets the angle between a part and a position

function CheckIfFacing(part,pos,checkAngle)
local Facing = part.CFrame.LookVector
local Vector = (pos - part.Position).Unit
local gotAngle = math.deg(math.acos(Facing:Dot(Vector)))
--print(gotAngle)
return gotAngle <= checkAngle
end