Why do these lines keep crashing my engine?

I can’t figure out why, but the following lines keep crashing my engine

Header file:

private:

//array which holds all players
    	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Zombies", meta = (AllowPrivateAccess = "true"))
    		TArray<AActor*> Players;
    
    	//array which holds the locations of the players
    	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Zombies", meta = (AllowPrivateAccess = "true"))
    		TArray<FVector> PlayerLocations;

	//Updates the location of the player to AZombieManager to be able to calculate zombiespawns
	void UpdatePlayerLocations();

cpp file:

void AZombieManager::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
	TimeSinceLastCalculation += DeltaTime;
	if (TimeSinceLastCalculation >= TimeBeforeNextCalculation)
	{
		UpdatePlayerLocations();
	}
}

void AZombieManager::UpdatePlayerLocations()
{
	for (int i = 0; i < Players.Num(); i++)
	{
		if (IsValid(Players[i]))
		{
			FVector TempVector = Players[i]->GetActorLocation();
			PlayerLocations[i] = TempVector;
			UE_LOG(LogTemp, Warning, TEXT("Succesfully updated player location"));
		}
	}
	TimeSinceLastCalculation = 0; // is initializeed in the header file didn't list it in the lines of the header file that has to do with this problem, but is is there as a float
}

It says that something is wrong in the AZombieManager::UpdatePlayerLocations() but what?

Thanks in advance

Is the PlayerLocations array always the same size as the Players array? Coz that would be one reason for the crash, accessing an index from PlayerLocations that exceeds its bounds. Ensure that when a Player is added to the array, that a vector is also added to the PlayerLocations array. And vice versa, if a player is removed, PlayerLocations is updated.

Please post the error log. We can help more then.