How to find the mouse delta using input.Position

I am trying to find the mouse delta when the mouse behavior is not locked. I have read a couple posts and say to use input.Position to find the mouse delta. How would I find the mouse delta using input.Position?

I believe youd do something like:

local uis = game:GetService("UserInputService")

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()

local last =, mouse.Y)
	if inp.UserInputType == Enum.UserInputType.MouseMovement then
		local pos =, mouse.Y)
		local delta = last-pos
		last = pos
		--do stuff