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()->