Issues with mouse X & Y

Hey, so I’m making a placement sort of system, I need to know how I can get the X & Y of where I’m pointing to, excluding the part I am using to show where it goes.

The Script
Mouse.Move:Connect(function()
if Item then
	local MouseTarget = Mouse.Hit
	
	--	Personal Folder
	if not workspace.placementSystem:FindFirstChild(Player.UserId) then
		local PlayerFolder = Instance.new("Folder", workspace.placementSystem)
		PlayerFolder.Name = Player.UserId
	end
	--
	local PlayerFolder = workspace.placementSystem:FindFirstChild(Player.UserId)
	
	--	Make cloned part forcefield like
	for _,Part in pairs(ItemCloned:GetDescendants()) do
		if Part:IsA("Part") then
			Part.Material = Enum.Material.ForceField
			Part.Color = Color3.fromRGB(85, 239, 196)
			Part.CanCollide = false
			Part.CanTouch = false
		end
	end
	--
	
	if not workspace.placementSystem:FindFirstChild(ItemCloned) then
		ItemCloned.Parent = PlayerFolder
	end
	
	ItemCloned:SetPrimaryPartCFrame(CFrame.new(math.floor(MouseTarget.X), math.floor(MouseTarget.Y), math.floor(MouseTarget.Z)))
else
	if workspace.placementSystem:FindFirstChild(Player.UserId) then
		workspace.placementSystem:FindFirstChild(Player.UserId):Destroy()
	end
end
end)

Video showing my issue in action

Could I have some ideas of how to overcome this issue and some suggestions for other problems you may see? :smiley:

So, basically what’s happening is the part you’re trying to move around is getting hit as the target, so you’ll want to add the part to a blacklist.

1 Like

Do you mean something like this: You want to get X and Y mouse’s position in 3D space? You can use these command to print X and Y position:
print("X position in 3D space: ", Mouse.Hit.X)
print("Y position in 3D space: ", Mouse.Hit.Y)

You can accomplish this easily by doing mouse.TargetFilter = thepartyouremoving but you might want to try a more involved approach if that wont work

4 Likes

They’re setting MouseTarget = Mouse.Hit.

My bad, Mouse.Hit might sometimes be not equal to MouseTarget in the script.

Add this to your code:

Mouse.TargetFilter = Item 

so your issue is that your not blacklisting your actual item so it bugs out

1 Like