How "bind" my system make in Lua (score,health) in HUD(text,progressive bar)

Hi, I have created in Lua a Health system that decreases when the player is colliding, I can see it with console debugging, same for the “score” that increases when I take an object. I want to know how to "bind"this data to the UI Progressive bar or convert the UI text with my variable score! This in Lua or in canvas script? some suggestions. thanks.

One way of accomplishing this is by creating an EBus that notifies when your values change and then updating in UI. Here is how it works in dev\MultiplayerSample project that ships with Lumberyard.

Here is the ebus:

    class HealthNotificationInterface : public AZ::ComponentBus
// HealthNotificationInterface
// Signal that the health was changed
virtual void OnHealthChanged(AZ::s32 health) = 0;
using HealthNotifications = AZ::EBus<HealthNotificationInterface>;

HealthComponent.cpp notifies:

    void HealthComponent::SetHealth(const AZ::s32 health)
m_currentHealth = CLAMP(health, 0, m_maxHealth);
EBUS_EVENT_ID(GetEntityId(), HealthNotifications, OnHealthChanged, *m_currentHealth);

HUDComponent.cpp picks it up and applies it to UI.

    void HUDComponent::OnHealthChanged(AZ::s32 health)
AZ::s32 maxHealth = health;
EBUS_EVENT_ID_RESULT(maxHealth, m_displayedEntity, HealthBus, GetMaxHealth);
float healthPercent = static_cast<float>(health) / static_cast<float>(maxHealth);
AZ::Vector3 currentHealthColour = AZ::Vector3(0.0f);
for (const HealthIconColour& iconColour : m_healthIconColours)
if (iconColour.ShouldHandleHealth(healthPercent))
currentHealthColour = iconColour.GetIconColour();
LyShine::Utils::TintImage(m_canvasID, k_hudHealthIndicator, currentHealthColour);

Thanks for reply,do you have an example Ebus in the LUA/ script canvas? I not have problems with communication lua script entity of world but i have problem with entity ui as they are different context. Thanks.