[SOLVED] Undefined values when referencing other scripts

Hi, I’m quite new to PlayCanvas and is currently working on a stamina function. So the issue is whenever the player sprints, it doesn’t register the player as sprinting in the stamina script. I tried to use console log to check the issue and found out that apparently the boolean “isSprinting” in my player script is undefined when referencing it from the stamina script. Is there something that I’m missing?

Your playerStaminaScript attribute is pointing to an entity, so this.playerStaminaScript.currentStamina is undefined, because there is no currentStamina on the entity.

If you want to access some script property on the entity, you should access its script component, for example entity.script.staminaScript.maxStamina.

1 Like

I see the issue now, thanks!