How do i fix that?

local a = game.Players.LocalPlayer:GetMouse()

this is the way to get player mouse?

Forget the mouse, I just mentioned it as an example. First decide your desired mechanics

Maybe you want to use the Camera looking vector, not the mouse nor the head

but i dont know how to detect if the player’s head is currently rotated at the eyes of the npc

What?.. Look, if the game is in FirstPerson, you can simply Raycast to the Camera Looking vector, you dont need to know the rotation of the head

dont mind it for some reason i always think of the hardest way to do things but i think that its the easiest.

1 Like

but how do i get the looking vector of camera when there is no option “LookVector”

You should research before being sure that something doesnt exist:

local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local lookingVector = camera.CFrame.LookVector
local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local A = camera.CFrame.LookVector
local B = game.Workspace.SCP080.Head.eyes

local Direction = B.Position - A

local Result = workspace:Raycast(A,Direction)

if Result and Result.Instance then
	
end

something like this?

Yeah kinda. But the Camera CFrame will be changing over time, in your pseudoScript you referenced the position of the Camera since the start and not constantly updating it on a loop.
The loop will constantly fire the Raycast, by using the Camera Origin position and firing the Ray towards the Camera.LookingVector by 100 studs.

Something like this. I made this script by asking chatGPT, cause Im lazy to type it myself, by quick reading it, it should work:

local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera

while true do
	local origin = camera.CFrame.Position
	local direction = camera.CFrame.LookVector * 100

	local raycastParams = RaycastParams.new()
	raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
	raycastParams.FilterDescendantsInstances = { player.Character }

	local result = workspace:Raycast(origin, direction, raycastParams)

	if result then
		if result.Instance.Name == "NPC_Eyes" then -- the name of the part in NPC
			print("Looking NPC eyes")
		end
	else
		print("Raycast did not hit anything.")
	end

	task.wait(1)
end

but chatGPT have only things from 2021 it could be outdated

btw its local script? where do i put it?

… so what?.. if you know how to script you can read what chatGPT made and you will know if it works or not or if its deprecated… and even if its using methods, properties or events that doesnt even exist… like it usually does… chatGPT sucks… but for very simple stuff like this its very performant. This script is not complex at all, I just didnt want to type it

doesnt work if i look at the part it doesnt say anything and i called the part “NPC_Eyes”

thats weird, Im gonna test it then…

it only says “Raycast did not hit anything” in the output

Works normally for me. It prints Looking NPC eyes when my camera is facing a Part called NPC_Eyes. You are doing something wrong

where you put the script or local script???

Obviously local script, you cant check the Camera CFrame from a ServerScript, Server doesnt know where the Client camera is facing

but where to put the local script?

In the client. I placed it in CharacterScripts, but PlayerScripts or CharacterScripts are the same, both are in the Client/Player