Endless runner gamemode c++ file won't spawn floors

I’m trying to make an endless runner game in c++, and don’t know why my gamemode is not allowing me to spawn floor. In my GameMode.h file, I have
class AFloor* MyFloor;
UPROPERTY(EditAnywhere)
TSubclassOf FloorClass;

This is my addfloor(), and I am calling this in BeginPlay().
Am I approaching this in a wrong way?