How can i make a frame resize/follow the mouse?

  1. What do you want to achieve? Keep it simple and clear!

So im making a small task/minigame inside my obby. I need a wire(In this case a frame) resize/follow the mouse.

Example of what i want:

  1. What is the issue? Include screenshots / videos if possible!

My issue is that i absolutley suck at math lol. This is the math/formula i got going atm which probs isnt the best XD

It works i guess. But its not the most efficient way im pretty sure.

local M = game.Players.LocalPlayer:GetMouse()

	local Dist = (M.X - script.Parent.Frame.AbsoluteSize.X / 2) 

	script.Parent.Frame.Size = UDim2.fromOffset(Dist,0)
  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

Ive tried lookin for some solutions. I found some but they werent exactly what i was looking for in this case sadly

Any help would be really cool because im stuck here lol. If i cant get this solved im afraid im going to have to switch up this task in the game.