Why is mouse.hit.p.y not accurate?

Hi everyone. I was wondering how to make a fixed axis dragging system for my placement system. While the x and z axis dragging is going well, I am having trouble fixing it to the y axis. Any fixes to this?

		if Axis == "All" then
			Target.Position = Mouse.Hit.Position + Vector3.new(0,Target.Size.Y/2,0)
		elseif Axis == "X" then
			Target.Position = Vector3.new(Mouse.Hit.Position.X, Target.Position.Y, Target.Position.Z)
		elseif Axis == "Y" then

			Target.Position = Vector3.new(Target.Position.X, Mouse.Hit.p.Y, Target.Position.Z)

		elseif Axis == "Z" then
			Target.Position = Vector3.new(Target.Position.X, Target.Position.Y, Mouse.Hit.Position.Z)
1 Like

If your mouse is in the sky (or not at a part), then Mouse.Hit.p is at an insane distance. It might be because of this?

You could maybe create a transparent part which acts as a Y plane?

How would this help tho? Would you mind explaining more?

If you have a part on the same X & Z coordinates as you wish to lock it on, then the mouse would hit this part’s surface. If it hits this surface you will be able to get an accurate Y value. Making it transparent is only to hide it from the user, figured you might’ve wanted it hidden.

Oh I understand now. Let me try it and I will get back to you.

Ok so it did work, however, whenever the player hovers over another object when they are dragging, it gets all messed up. How would I fix this?

Can you provide a video/image?

You need to add the dragged BasePart instance to the mouse’s TargetFilter property.

mouse.TargetFilter = part

wdym by dragged basepart instance?