Unable to assign property position. vector3 expected, got number

im trying to magnitude the player’s currentcamera and mouse position

(Camera.CFrame.Position - Mouse.Hit.Position).Magnitude

but error on output says: Unable to assign property Position. Vector3 expected, got number?

Are you assigning the magnitude to something? It could be that as the magnitude is the number its referring to

Magnitude returns a number(Specifically the length of the vector)
When you do (Vector3 - Vector3).Magnitude you’re actually getting the distance between those 2 Vectors

The error is that you’re trying to set something’s Position(Vector3) to a number(Magnitude) which isn’t possible. Can we have the full line where the error is?

i’m positioning a part that mouse.target finds

local UIS = game:GetService("UserInputService")
local Player = game:GetService("Players").LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Mouse = Player:GetMouse()
local Camera = game.Workspace.CurrentCamera

local Selected
local Holding

UIS.InputBegan:Connect(function(Input)
	if Input.UserInputType == Enum.UserInputType.MouseButton1 then
		if Mouse.Target then
			if Mouse.Target:FindFirstChild("toggle") then
				if Mouse.Target:FindFirstChild("toggle").Value == true then
					Holding = true
					Selected = Mouse.Target
					Mouse.TargetFilter = Selected
				end
			end
		end
	end
end)

UIS.InputChanged:Connect(function(Input)
	if Input.UserInputType == Enum.UserInputType.MouseMovement then
		if Holding == true and Selected ~= nil then
			Selected.Position = (Camera.CFrame.Position - Mouse.Hit.Position).Magnitude
		end
	end
end)

As I said before Magnitude is a number and when used in this way is the distance between 2 points.

Could you be more specific on how you want to position the part that the mouse finds?
Like follow the mouse?

ohh i think its fixed now like this

local Distance = (Selected.Position - Character.Head.Position).Magnitude
Selected.Position = Character.Head.Position + (Mouse.Hit.Position - Character.Head.Position).Unit * Distance