How would I make eyes look at the mouse?

Something like this:

yes
yes

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 = UDim2.new(0, x, 0, y)
		end
	end
end	

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

Hopefully somebody can help :smiley:

Thanks,
Dragon

3 Likes

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
image

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)