Dragged Mouse Path Detection?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I’m trying to make a system where you drag to “build.” What I mean by this, is, for example:

Player clicks and drags mouse upward from a baseplate.
A block appears and it stretches to the position of your mouse from the starting position at the baseplate.

Now, im trying to figure out how to do this but also how to figure out the “angle.” An example is detecting when a player is dragging diagonally and the angle of the path.

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

I know it has something to do with calculating the current mouse’s position with the starting position, but I’m not sure how to do that for diagonal usage.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I’ve searched online and found this link, which shows how to do this but only one axis.

Any help is appreciated!

local players = game:GetService("Players")
local player = players.LocalPlayer
local mouse = player:GetMouse()
local camera = workspace.CurrentCamera

local baseplate = workspace:WaitForChild("Baseplate")

local downMouseY, upMouseY

mouse.Button1Down:Connect(function()
	if mouse.Target == baseplate then
		downMouseY = mouse.Y
	end
end)

mouse.Button1Up:Connect(function()
	if not downMouseY then
		return
	end
	
	if mouse.Target == baseplate then
		upMouseY = mouse.Y
		if downMouseY - upMouseY > camera.ViewportSize.Y/2 then
			local part = Instance.new("Part")
			part.Parent = workspace
		end
	end
end)

Does this help? A system similar to what you describe.

https://gyazo.com/5eff885616d398e9b364740bebefb5c5

If you click the mouse button on a part named “Baseplate” and drag your mouse upwards such that you drag over a half of the screen’s Y dimension’s size (Y axis resolution) and release the button on the same part named “Baseplate” a BasePart instance is created and placed in the worldspace (3D environment).

Thanks for the reply. However, I was asking about dragging the mouse upward to the sky and the block would extend to there. Although, your code gave me an idea for that, so I’ll give it a go.