Can't make function Blueprint callable

Got it working no problems.

.h

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "CreateBlueprint.generated.h"

/**
 * 
 */
UCLASS()
class SWAPYOUR_API UCreateBlueprint : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()

public:
		UFUNCTION(BlueprintCallable, Category = "NodesToScript")
		static UBlueprint* CreateBlueprint(FString BlueprintPath, TSubclassOf<UObject> ParentClass, bool& bOutSuccess, FString& OutInfoMessage);
};

cpp

// Fill out your copyright notice in the Description page of Project Settings.


#include "CreateBlueprint.h"
#include "Kismet2/KismetEditorUtilities.h"
#include "KismetCompilerModule.h" 
#include "AssetRegistry/AssetRegistryModule.h"

UBlueprint* UCreateBlueprint::CreateBlueprint(FString BlueprintPath, TSubclassOf<UObject> ParentClass, bool& bOutSuccess, FString& OutInfoMessage) 
{		
	if (StaticLoadObject(UObject::StaticClass(), nullptr, *BlueprintPath) != nullptr) {
		bOutSuccess = false;
		OutInfoMessage = FString::Printf(TEXT("Create Blueprint Failed - An asset already exists at that location. '%s'"), *BlueprintPath);
		return nullptr;
	}

	if (!FKismetEditorUtilities::CanCreateBlueprintOfClass(ParentClass)) {
		bOutSuccess = false;
		OutInfoMessage = FString::Printf(TEXT("Create Blueprint Failed - Parent class is not blueprintable '%s'"), *BlueprintPath);
		return nullptr;
	}

	UPackage* Package = CreatePackage(*BlueprintPath);
	if (Package == nullptr) {
		bOutSuccess = false;
		OutInfoMessage = FString::Printf(TEXT("Create Blueprint Failed - Failed to create asset package. Make sure path is valid '%s'"), *BlueprintPath);
	}


	UClass* BpClass = nullptr;
	UClass* BpGenClass = nullptr;
	FModuleManager::LoadModuleChecked<IKismetCompilerInterface>("KismetCompiler").GetBlueprintTypesForClass(ParentClass, BpClass, BpGenClass);

	UBlueprint* Blueprint = FKismetEditorUtilities::CreateBlueprint(ParentClass, Package, *FPaths::GetBaseFilename(BlueprintPath), BPTYPE_Normal, BpClass, BpGenClass);

	FAssetRegistryModule::AssetCreated(Blueprint);
	Blueprint->MarkPackageDirty();

	bOutSuccess = true;
	OutInfoMessage = FString::Printf(TEXT("Create Blueprint Succeeded '%s'"), *BlueprintPath);
	return Blueprint;

}

in build

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });

PrivateDependencyModuleNames.AddRange(new string[] { "UnrealEd", "KismetCompiler", "AssetRegistry" });

Make sure you are in an Editor Utility Widget or other variations of the Editor Utility.

You can’t be in a normal widget or actor blueprint.