I can't cook my project which has c++ functions

I have recently started to learn c++ with unreal engine and i am learning the basics. So i made a destroy function and added the UFUNCTION in the header file in c++ and called the function in blueprints and it worked well but when cooking project or packaging it i get this error: UATHelper: Cooking (Windows): LogInit: Display: LogBlueprint: Error: [Compiler] In use pin <Unnamed> no longer exists on node destroy . Please refresh node or break links to remove pin. from Source: /Game/FirstPerson/Blueprints/BP_FirstPersonCharacter.BP_FirstPersonCharacter UATHelper: Cooking (Windows): LogInit: Display: LogBlueprint: Error: [Compiler] Could not find a function named "destroy" in 'BP_FirstPersonCharacter_C'.

It seems that your BP_FirstPersonCharacter file has some invalid destroy function.
Is your function Blueprint callable? Could you post the code related to the function?

UFUNCTION(BlueprintCallable)
void destroy();

i have checked and it is indeed blueprint callable and note that when i play the game in editor it works i only have the error while cooking and packaging and here is my destroy function: **

void ACppTestCharacter::destroy() {

FVector start = GetActorLocation();

FVector end = FirstPersonCameraComponent->GetForwardVector() * 20000.f;

FHitResult result;
FCollisionQueryParams params;

GetWorld()->LineTraceSingleByChannel(result, start, end, ECollisionChannel::ECC_Visibility, params);

if (result.GetActor() != nullptr) {
	result.GetActor()->Destroy();
}}

In your BP_FirstPersonCharacter, right click in destroy function and click in Refresh Node, the problem seems to be with name or parameters or something that changed the declaration in C++ that wasn’t updated in Blueprint, so you need to fix the Blueprint side.