How would I detect if a part is infront or behind the player?

If it’s a server script, Roblox uses their computer.

Still it’s the difference between checking one part and all parts

To determine if the football is in front of the red player:

footballCF:ToObjectSpace(redPlayerCF).Z > 0
1 Like

Instead of changing method, would there be a way to alter the script to repeat the loop and check for parts that are infront of the player?

1 Like

okay, ive figured it out.

  		local isInfront = false
  		local isNextTo = false
  		if Core then
  			local angle = math.acos(Core.CFrame.LookVector:Dot((Child.Position-Core.Position).Unit))
  			isInfront = angle < math.pi/2
  			isNextTo = angle < math.pi/1.65
  		end
  		
  		if isInfront or isNextTo then
11 Likes