Function when called crashes the editor and game

I tried this but it still crashes. I don’t suppose that you have any more ideas?