'Apps Sripts are not executed on shared Google Sheet

I got a Apps Script (onEdit) running, that locks certain cells when a particular time is over, and it also makes a time stamp. The script works perfectly, but only when I use it myself. As soon as some (whom I shared the document to) opens it, they can edit all the protected cells and the timestamp doesn't appear. So the script doesn't run. How do I fix this?

//https://stackoverflow.com/questions/65708006/multiple-data-validations-in-google-sheets-problem

function onEdit(e) {
  var row = e.range.getRow();
  var col = e.range.getColumn();
  var cell = e.range;
  var ui = SpreadsheetApp.getUi();

  //TIME STAMP

  if(e.source.getActiveSheet().getName()=="Member Data") {
    if(col == 9){
      e.source.getActiveSheet().getRange(row,11).setValue(new Date());
    }
  }

  //CELL LOCK

  if(e.source.getActiveSheet().getName()=="Member Data") {
    if(col == 9 && cell.offset(-1,-6).getValue() < new Date()){

      //Display warning message
      ui.alert(
        'Warning',
        'You cannot modify cells that are closed, returning the original value of the cell',
        ui.ButtonSet.OK
      )
      //return cell to its original value
     cell.setValue(e.oldValue);
    }
  }
}


Solution 1:[1]

@Rubén gave the answer in the comments:

I created an "onEdit" trigger for the "onEdit" script. Now the script is not only executed when the owner uses the doc, but also when others use it. It makes no sense to me, but it works.

Thank you!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 JagsUprising