How do I make an eye look at a part?

I found this character on the toolbox, and I saw that I can change the facial controls within the facial controls instance, so I had the idea to make the eyes follow a part.
Screenshot (763)
Screenshot (762)
It uses a scale from 0-1, and in all directions. Anyone know how I can do this?

3 Likes

Instead of customizing the face editor, you may want to look into raycasting, for example:

local target = --put in the part that you want the eyes to look at
local eyeOrigin = --THIS SHOULD BE THE PRIMARY PART OF EACH EYE!

local function followPart()
    local rayOrgin = eyeOrigin
    local rayTarget = target
    
    workspace:Raycast(rayOrigin, rayTarget)
    
    eyeOrigin.CFrame = target.CFrame
end)

followPart()

Well the eye is part of the head, it isn’t a part or meshpart, so I can’t change it at all without the face editor.

Alright then, change this line:

To the custom face editor properties
P.S. You may have to do some math which may require returning the rayDistance of the raycast in order to calculate where the eyes should look

Why do I even need to do raycasts? All I need is a position right?

Raycasting will cast the ray to the part and stay there even if the part is moving, all you need to do is calculate the X and Y axis movements that the eyes should do to stare at the part

I have used RayCasts when making Laserguns in my games, So it also works with things like eyes?

Raycasting wasn’t only made for guns, it is very helpful on the math side to find out positioning and other things to get the right movement or orientation

Thats interesting! is there like a whole guide to Basic things you can do with Raycasts?

Yes, if you need to understand more about it this is the link: Intro to Raycasting

Thank you so much! i will check it out right now.