I'm currently trying to make a targeting system, but it's not working how I want it to. Whenever I try to make it work, it marks everything on my screen, yet I want it only to do that within a certain radius.(For example, looking through a scope; you can only see the things in front of you. That's what I meant by radius.) Is this even possible? Here is my script:
function Target()
local b = Cam:WorldToScreenPoint(human.Torso.CFrame.p)
if (b==true) then
local Spot= Spot:Clone()
Spot.Parent=human.Parent.Head
end
end

5 comments
What do you mean by it marks everything on your screen?
It clones the spot to every humanoid on my screen.
It is posible, you need to create a view frustum representing the view of the scope and then do a frustum culling. It involves some math but you can start googling. If I have time I'll implement it, seems interesting doing it in Roblox. EDIT: Checked the API, WorldToScreenPoint does the math for you, it returns a secound value telling if that point is visible.
Use a part's CFrame.lookVector to get the direction it's facing, then use one of many methods to get objects in this direction (raycasting?) then check if those objects are characters. Place the characters into a table for use when cloning Spot through a generic for loop.
Add on: match characters from table to WorldToScreenPoint characters to specifically those in front of you.