Flatworms play important roles in the ecosystem as both predators and prey. Some flatworms are scavengers, while others help to break down dead organic matter.