Measure carefully with a tape measure as you place the vertical studs in position during construction. Make sure that the tops and bottoms of the studs are exactly the same distance from the ends of the frame wall.
Place a carpenter's square onto each of the vertical studs and the top and bottom plates as you place the vertical studs. If the vertical studs are not square and even with the carpenter's square, your measurements are off. Remeasure and reset the vertical studs.
Place a level against the front edge of the stud wall after you've set it into position but before nailing the top plate to the ceiling joist. Tilt the wall forward or backward to get the bubble in the level between the lines. Doing this will ensure the wall is plumb -- straight up and down. Nail the top plate into the ceiling joists when it's correctly set.