How to move a 3D block into the mouse position?

Hey guys! I hope you all do very very well! Being direct, I’m trying to constantly move a block from the Workspace to the player’s mouse position. The problem is that the mouse doesn’t have a “mouse.Z” so I can’t complete the script without it giving an error (because of the missing Z position).

I’ll be grateful with you if you can give me a hand with this, even if it’s the smallest one, thanks for reading, and here’s the script if you can help:

(I’m trying to move the block without clicking it and when the mouse position changes) so if you move the mouse to a wall for example, the block will go to the exact same mouse position:

Something like this:

Here’s the script:

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
--This is the block name (Target)
local mTarget = game.Workspace.Target

mouse.TargetFilter = mTarget

mouse.Move:Connect(function()
	
	local posX, posY = mouse.X, mouse.Y
	local posZ 

	mTarget.Position = Vector3.new(posX, posY)
	
end)

Thank you for reading and have a nice day! byee! :grinning_face_with_smiling_eyes: :wink: :wave:

Just change the position to mouse.Hit.p and change it through that.

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
--This is the block name (Target)
local mTarget = game.Workspace.Target

mouse.TargetFilter = mTarget

mouse.Move:Connect(function()
	mTarget.Position = mouse.Hit.p
end)

but you get mouse.Hit.Position when you click your mouse or no?

Mouse.Hit.p will always be changed, even if just moving the mouse.

Thank you so much for not only helping me to fix this problem but to teach me a new thing! Have a nice day! :grinning_face_with_smiling_eyes: :wink: :wave: