There are easier ways to trigger code when someone dies. One way is to use the events provided by the “baseevents” resource. You can find them on the docs.
Another way (that doesn’t involve while-loops) is to use the “game events”. I wrote a post about them here.