Guys help me please

guy,i can’t fix the bug in level 26 game dev island
here it’s,you can try

here is my code

player = game.spawnPlayerXY("captain", 40, 34)
player.health=300
scout=game.spawnXY("scout", 40, 5)
scout.attackDamage=150
player.maxSpeed = 20
game.score=0
itemInterval = 1
itemSpawnTime = 2
requiredScore = 200
goldGoal = game.addManualGoal('nhặt được ít nhất 200 điểm và tiêu diệt quái vật trong 90s')
game.addDefeatGoal(1)
ui.track(game, "score")
ui.track(game,'time')
ui.track(game,'defeat')
def defeat():
    game.defeat+=1

def onSpawn(event):
    unit = event.target
    unit.attackDamage = 300
    while True:
        # Kẻ địch bỏ chạy khỏi người chơi to lớn.
        if game.score>=200:
            unit.maxSpeed=25
            player.attackDamage=1000
            unit.behavior = "RunsAway"
        else:
            unit.behavior = "AttacksNearest"

def spawnRandomItem():
    itemNumber = game.randomInteger(1, 5)
    ssr=game.randomInteger(1, 50)
    x = game.randomInteger(12, 68)
    y = game.randomInteger(12, 56)
    if ssr==9:
        game.spawnXY("chest", x, y)
    if itemNumber <=2:
        game.spawnXY("bronze-coin", x, y)
    else:
        if itemNumber ==3:
            game.spawnXY("gold-coin", x, y)
        else:
            if itemNumber ==4:
                game.spawnXY("gem", x, y)
            else:
                trap=game.spawnXY("fire-trap", x, y)
                game.spawnXY("gold-coin", x, y-2)
                trapdespawntime=game.time+5
                if trapdespawntime==game.time:
                    trap.destroy

def checkSpawnTimer():
    if game.time >= itemSpawnTime:
        spawnRandomItem()
        itemSpawnTime += itemInterval

def onCollect(event):
    item = event.other
    if item.value:
        game.score += item.value

def checkGoals():
    if game.score >= requiredScore:
        game.setGoalState(goldGoal, True)
    else:
        if game.time>=90:
            game.spawnXY("fire-trap", player.pos.x, player.pos.y)

while True:
    if player.health>0:
        checkSpawnTimer()
    checkGoals()
    scout.on('spawn',onSpawn)
    player.on('collect',onCollect)

I’m so confused. What is the bug you’re talking about? The code runs just fine.

when i picked up a gem or coin it plus for my score up to 200+ instead of their value