How to change the text dynamically

Hi, I’m trying to make a score board. It fetches the score from an array called TimeBoard saved in SaveGameObject, and then set that to the text block object.
There are 3 text block objects; 1stPlace Txt, 2nd Place Txt, and 3rd Place Txt. Their “Is Variable” is true, their default value i.e. the text set in the “Content” section is “A”, “B”, “C”, and I am setting them as a target of each “Set Text” node. When I run the game, the text doesn’t display the score and stays as “A”, “B”, “C.”
For debugging purposes, I:

  • added print statement right after calling DisplayScore, and print the first score stored in the array. These print statements shows that DisplayScore is successfully called, and the score stored in the array is accurate.
  • Passed a string directly as Set Text’s parameter. Still displays “A” “B” “C,” not the string I passed to Set Text.
  • When I bind a text variable to the text block object, now it displays nothing instead of displaying the default value. This holds true no matter what value I set to the text variable

Can you change the text with a hardcoded value and say if it is displayed properly:

My thought is either 1stPlaceTxt variable is not set properly or something overrides it after DisplayScore is called.

Hey there @Oriori_oriOri! I agree with Dz here, this is the correct way to set the text itself. Barring no other factors like networking, it seems possible that your variables aren’t being set correctly before this. Give Dz’s recommendation a try first, maybe verify the targets are correct and valid.

Thanks for the reply; I actually tried that already, and the text still stayed as “A” (the default value).

I’m calling DisplayScore event from different WBP which is created and displayed in different level. Could this be the issue?
Levels: LV_Menu, LV_Rankings
WBP: WBP_Menu (UI in LV_Menu), WBP_Rankings (UI in LV_Rankings)

Nodes in WBP_Menu

Nothing executes after open level function.
You need to create widget and display score in the new level.

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.