FindFunctionByName always yields nullptr

if (!Blueprint)
{
// Blueprint is null, handle the error
return;
}

UClass* BlueprintClass = Blueprint->GeneratedClass;
if (!BlueprintClass)
{
	// The blueprint class is null, handle the error
	return;
}

FName FunctionName = FName(TEXT("DestroyActor"));
UFunction* Function = BlueprintClass->FindFunctionByName(FunctionName);
if (!Function)
{
	// The function does not exist in the blueprint class, handle the error
	UE_LOG(LogTemp, Warning, TEXT("Function Not Found"));
	return;
}

The Bluepirnt is subclass of Actor
I’ve tried different variations of “Destroy Actor” and “DestroyActor”, and several other functions, but they always return nullptr. What am I doing wrong?

I see, I had to use “K2_DestroyActor” as the name.
I found the name by Right-clicking “Destroy Actor” node on graph, and pasting into text editor, show as “MemberName =”.

This finds some functions, but not others.
FunctionReference=(MemberParent=/Script/CoreUObject.Class’“/Script/Engine.GameplayStatics”',MemberName=“GetActorOfClass”)

“GetActorOfClass” return nullptr
but
K2_DestroyActor works

FunctionReference=(MemberName=“K2_DestroyActor”

The difference appears to be “MemberParent”. How can I find functions available for any blueprint class?

I’m trying to get to the point where I add nodes that exist in a plugin “Geometry Scripting” to a blueprint that is a child of “GeneratedDynamicMeshActor”, but it always yields a nullptr.

I get it now. Instead of setting “BlueprintClass” to the class of the blueprint, I have to set it to the class that the function exists in.

“GameplayStatics” UClass In the example of “GetActorOfClass” function