Why do i keep getting this error.

Hi quick question. I have a hp bar on a HUD overylay scene that keeps my HP bar updated on the overlay scene. THe script works properly but i get this error

##############################################
####KEEP PLAYER HP BAR UPDATED ON OVERLAY SCENE
#############################################
activeScenes = logic.getSceneList()

hudscene = activeScenes[1] ##<----ERROR HERE
hudhpbar = hudscene.objects[‘playerhpbar’]
hudhpbar[‘playerhp’] = int(owner[“playerhp”] * 100 / owner[“playermaxhp”])

“list index out of range”
Although it works properly. I hate error messages. Any help on this is greatly appreciated

Also there is only 2 scenes. The main scene which i assume was [0]. And Overlay(HUD) would be [1]

You’re probably running that script before the overlay scene is actually added in.

Waiting until the overlay scene is actually added, or putting everything under an “if len(activeScenes) > 1:” block should solve the problem.

Edit: Completely misread your post before I answered

Thanks for the Help :smiley:

Edit Edit: Worked perfectly. Thanks again