Error: 'Function' is not allowed before the Class definition

A UFUNCTION has to be inside a UCLASS. Yours is declared outside any class and is later defined inside UCreateNewObject.