How do I find slow/unoptimized function/event?

Hi there guys and thanks very much for your help!

This is the script that I’m trying to optimize. I’ve been trying different things and I just can’t pin down which part is causing the issue.

When running the resource, after about 30 minutes or so, players will get a 6ms warning. That will slowly climb. I’ve been on long enough to get it to 25 ms. All players online(joined the same time as me) were showing almost exact same ms warnings so it’s climbing at the same speed for everyone.