Only execute only when target is in the scene.

Hi all, i am having a little difficult with this code. As you can see here, it makes every object that has the property ‘hilight’ play an action.

But now i want to apply the vm[‘frame’] to another object, that has a property [‘pikachu’] to make them move synchronizingly together with ‘hilight’ - objects.

The object with the property pikachu is not in every blendfiles that my game libloads and the script is in the main blendfile.

I want that ,if the script doesnt find any object with property [‘pikachu’] it can then ignore that line and continue like usual.

Thank you in advance

from bge import logicfrom mathutils import Vector


vm=logic.globalDict
scene = logic.getCurrentScene()
cont = logic.getCurrentController()
own = cont.owner
obs = scene.objects




#Blinking for character customization
if vm['player'] !='playing':            
    for obj in obs:
        if 'hilight' in obj:
            obj.playAction('highlightBW', 0, 240, play_mode = 2, speed = 1.415)
            vm['frame'] = int(obj.getActionFrame())
            #print (vm['frame'])
    
    
#Blinking DURING THE DANCE
else:
    anispe = vm['speed']
    
    if vm['hili'] == 0:
        for obj in obs:
            if 'hilight' in obj:
                obj.playAction('highlightcol', 0, 0, play_mode = 2, speed = 0)     
                own.stopAction(0)
                vm['frame'] = int(obj.getActionFrame())
                #print (vm['frame'])                      


    if vm['hili'] == 1:    
        for obj in obs:
            if 'hilight' in obj:
                obj.playAction('highlightBW', 0, 240, play_mode = 2, speed = anispe)
                vm['frame'] = int(obj.getActionFrame())
                
    if vm['hili'] == 2:    
        for obj in obs:
            if 'hilight' in obj:
                obj.playAction('highlightcol', 1, 241, play_mode = 2, speed = anispe)
                vm['frame'] = int(obj.getActionFrame())
                #print (vm['frame'])




for object in scene.objects:
    if 'pikatchu' in object:
        doTheStuff...

Isn’t this it?