I tried by printing another screen message in the if statement, and it is working here, which means that the logic is fine. But, somehow it is printing both the screen messages “Widget added to viewport” and “Cannot add widget to viewport” upon begin play