How can i make a part follow the mouse like this?

I am trying to make a part move like this when i move my mouse around how would I start it or what way would work?
https://gyazo.com/8c75fdccdb79439c7048f2c9fe7b6e2c.mp4

From the video you sent, it seems like just a tween and a simple mouse tracking script.
Id recommend doing it on the client however. Your best bet is to use mouse.Hit.Position.
You can get the players mouse on the client by doing plr:GetMouse()

I admit it might not be the best method performance-wise, but it works consistently at least (LocalScript inside of StarterPlayerScripts):

local Workspace = game:GetService("Workspace")
local ContextActionService = game:GetService("ContextActionService")

local TIME = 0.5 -- How many seconds does it take for part to reach mouse position

local currentCamera = Workspace.CurrentCamera or Workspace:WaitForChild("Camera")

local part = script:WaitForChild("Part") -- Change this to the Part you want to make follow the mouse
part.Parent = Workspace -- You can remove this line if the Part's already in workspace

local offset = part.Size.Y / 2 * Vector3.yAxis

local raycastParams = RaycastParams.new()
raycastParams:AddToFilter(part)

local thread = nil
local originalPosition = nil

TIME = 1 / TIME

local function mouseMovement(_, _, inputObject)
	local ray = currentCamera:ScreenPointToRay(inputObject.Position.X, inputObject.Position.Y)
	local raycastResult = Workspace:Raycast(ray.Origin, ray.Direction * 1024, raycastParams)

	if thread then task.cancel(thread) end

	originalPosition = part.Position

	thread = task.spawn(function()
		if raycastResult then
			local x = 0

			repeat
				x = math.min(x + task.wait(0) * TIME, 1)

				part.Position = originalPosition:Lerp(raycastResult.Position + offset, x)
			until x == 1
		else
			local x = 0

			repeat
				x = math.min(x + task.wait(0) * TIME, 1)

				part.Position = originalPosition:Lerp((ray.Origin + ray.Direction * 1024) + offset, x)
			until x == 1
		end
	end)
end

ContextActionService:BindAction("MouseMovement", mouseMovement, false, Enum.UserInputType.MouseMovement)
2 Likes