The answer can be seen here:
Add this function to a BP Function library, and please read my comment in the answer section (the code isnt 100% functional when you dont change it a bit):
You can’t use this code for a BP Function, because BP doesnt allow you to set the world parameter, it just wont save the bp. What you have to do instead, is to get a reference to an Object, from this object get the world. Replace UWorld* World with UObject InputObject, and World-> with InputObject->getWorld()->