How would I make the cursor dynamically move depending on the head movement?

Hey there! I want to make my cursor move in the opposite direction of the head, like this:
https://streamable.com/v8x0u0

Here is the code I’m currently using to track the head position:

runService.RenderStepped:Connect(function()
	newCamCF = character:WaitForChild("Head").CFrame:ToObjectSpace(humanoid.RootPart.CFrame)

	if oldCamCF then
		local _,_,z = newCamCF:ToOrientation()
		local x,y,_ = newCamCF:ToObjectSpace(oldCamCF):ToEulerAnglesXYZ()
		
		angles = CFrame.Angles(x/100*headPercentage,y/100*headPercentage, -z/100*headPercentage)

		cam.CFrame = cam.CFrame * angles
		
		script.Parent.Position = UDim2.new(0,mouse.X,0,mouse.Y)
	end

	oldCamCF = newCamCF
end)

I have no idea how I would even begin to do this. Any help is appreciated!

1 Like