I didn't know there was a recycle bin in moodle so they weren't exactly deleted that's why it didn't run, also cron script doesn't run automatically on local so the recycle bin wouldn't even show up so I just disabled it.
General developer forum
How can I run a function when a course module is deleted in moodle?
Keskustelu on lukittu, joten et voi enää vastata siihen.