Preview:
trigger ClosedOpportunityTrigger on Opportunity (after insert, after update) {
    
        List<Task> tasklist=new List<Task>();
    
        for(Opportunity opp: [SELECT Id, StageName FROM Opportunity WHERE StageName='Closed Won'
                              AND Id IN : Trigger.New])
          tasklist.add(new Task (Subject='Follow Up Test Task', WhatId=opp.Id));
                 
          if(tasklist.size() > 0) {
             insert tasklist;
          }
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter