How to detect if mouse is inside a part?

I want to make a zone where any player that is currently inside the zone can teleport to anywhere else inside the zone with a click of a mouse. I was wondering how I can do this and detect mouse position. Here is what I currently have but it des not work.

local room = game.Workspace:FindFirstChild(Player.Name.." OpeRoomMesh")
			local Distance = (Mouse.Hit.p - room.Position).magnitude
			
			if Distance > room.Mesh.Scale.X then
				return
			elseif Distance < room.Mesh.Scale.X then
				print(Mouse.Hit.p)
1 Like
  1. i think its Magnitude not magnitude
  2. try printing the Distance variable
  3. add = statement. So it will check if Distance <= instead of just checking if its more.
  4. I think you meant to do room.Mesh.Scale.Position.X instead of room.Mesh.Scale.X
    However, i dont think that Magnitude and Position.X are comparable values