The rope is connected to a noise maker on the 2nd floor here. The intruder would then think that the ninja is on the 2nd floor and go up the ladder in pursuit. When the intruder is on the 2nd floor, the ninja below the trap door would remove the ladder.