How would I make eyes look at the mouse?

Something like this:


This is my current script:
local uis = game:GetService(“UserInputService”)

while wait() do
	local mouseLocation = uis:GetMouseLocation()

	local eyeSize = player.Eye.AbsoluteSize
	print("Mouse Location: "..mouseLocation.X, mouseLocation.Y)
	print("Size: "..eyeSize.X, eyeSize.Y)
	for _, v in pairs(script.Parent:GetChildren()) do
		if v ~= script then
			local eye = v
			local pupil = eye.Pupil

			local x = math.clamp(mouseLocation.X, 0, eyeSize.X)
			local y = math.clamp(mouseLocation.Y, 0, eyeSize.Y)

			pupil.Position =, x, 0, y)

It sort of works, but it doesn’t work properly. This is how it works:

Hopefully somebody can help :smiley:



maybe put the eyes on the side of a Gui
Then rotate the Gui according to the mouse!

I don’t know how exactly you would do that?
but hope this helps!

1 Like

This is how the imagelabel looks in the Explorer

I’m not sure if this is what you mean, but it should be moving the pupil relative to the eye.

You need to subtract the AbsolutePosition plus the GuiInset (regardless of whether or not your ScreenGui.IgnoreGuiInset is set to true, as AbsolutePosition is always relative to the inset) of each eye from the positions of your mouse coordinates. That will change the coordinates from being relative to the top-left corner of the screen to being relative to the top-left corner of each eye, as desired.

1 Like

By GuiInset, do you mean GuiService:GetGuiInset

(just making sure)

Nevermind, I figured it out. Thanks!

1 Like

Can you post the finished version here? (if you still have it ofc)