how to use variables from other class in ue5 c++?

When you declared your PartyInfo variable you did not assigned a value. Since it is a pointer, it will be a nullptr and that condition will always fail.

Your declaration

APartyInfo* PartyInfo;

Should be:

APartyInfo* PartyInfo = NewObject<APartyInfo>(args...);

If your PartyInfo object already exists, you need to get its reference from somewhere.