Game Dev. 2 Final Project Help

For some reason, (it dosen’t say which line) it says "cannot read property ‘start’ of undefined. Here is my code. It’s pretttty long.

# Create your own game!
def onSpawn(event):
    unit = event.target
    while True:
        enemy = unit.findNearestEnemy()
        if enemy:
            unit.attack(enemy)
game.setActionFor("scout", "spawn", onSpawn)
game.setActionFor("ogre", "spawn", onSpawn)
game.setActionFor("soldier", "spawn", onSpawn)
game.setActionFor("archer", "spawn", onSpawn)
# Spawn a player with spawnPlayerXY()
game.spawnXY("scout", 60, 58)
game.spawnXY("scout", 28, 29)
game.spawnXY("scout", 61, 24)
game.spawnXY("scout", 60, 58)
game.spawnXY("scout", 28, 29)
game.spawnXY("scout", 61, 24)
game.spawnXY("scout", 60, 58)
game.spawnXY("scout", 28, 29)
game.spawnXY("scout", 61, 24)
game.spawnXY("scout", 60, 58)
game.spawnXY("scout", 28, 29)
game.spawnXY("scout", 61, 24)
game.spawnXY("scout", 60, 58)
game.spawnXY("scout", 28, 29)
game.spawnXY("scout", 61, 24)
game.spawnXY("scout", 60, 58)
game.spawnXY("scout", 28, 29)
game.spawnXY("scout", 61, 24)
game.spawnXY("scout", 60, 58)
game.spawnXY("scout", 28, 29)
game.spawnXY("scout", 61, 24)
game.spawnXY("scout", 60, 58)
game.spawnXY("scout", 28, 29)
game.spawnXY("scout", 61, 24)
game.spawnXY("scout", 60, 58)
game.spawnXY("scout", 28, 29)
game.spawnXY("scout", 61, 24)
game.spawnXY("scout", 60, 58)
game.spawnXY("scout", 28, 29)
game.spawnXY("scout", 61, 24)
game.spawnXY("scout", 60, 58)
game.spawnXY("scout", 28, 29)
game.spawnXY("scout", 61, 24)
game.spawnXY("scout", 60, 58)
game.spawnXY("scout", 28, 29)
game.spawnXY("scout", 61, 24)
game.spawnXY("scout", 60, 58)
game.spawnXY("scout", 28, 29)
game.spawnXY("scout", 61, 24)
game.spawnXY("scout", 60, 58)
game.spawnXY("scout", 28, 29)
game.spawnXY("scout", 61, 24)
ogref = game.spawnXY("ogre-f", 60, 12)
game.spawnXY("soldier", 36, 30)
# Spawn and configure the hero.
hero = game.spawnHeroXY("necromancer", 12, 51)
hero.maxHealth = 666
hero.maxSpeed = 20
hero.attackDamage = 15
game.spawnMaze(1)
# Spawn a munchkin generator.
generator = game.spawnXY("generator", 41, 13)
generator.spawnDelay = 1
generator.spawnType = "munchkin"
generator = game.spawnXY("generator", 41, 13)
generator.spawnDelay = 10
generator.spawnType = "ogre-f"
generator = game.spawnXY("generator", 41, 13)
generator.spawnDelay = 3
generator.spawnType = "skeleton"
generator = game.spawnXY("generator", 41, 13)
generator.spawnDelay = 5
generator.spawnType = "ogre"
generator = game.spawnXY("generator", 41, 13)
generator.spawnDelay = 2
generator.spawnType = "thrower"
# Survive goal.
game.addSurviveGoal()
game.spawnXY("potion-medium", 28, 12)
game.spawnXY("potion-medium", 28, 12)
game.spawnXY("potion-medium", 28, 12)
game.spawnXY("potion-medium", 28, 12)
game.spawnXY("potion-medium", 28, 12)
game.spawnXY("potion-medium", 28, 12)
game.spawnXY("potion-large", 63, 51)
# addManualGoal adds an incomplete goal with a description
# The description will be shown to players.
# NOTE that we save it in a variable!
# Assign the onDefeat handler to the ogres" "defeat"
# NOTE that munchkins don't count toward success!
game.spawnXY("archer", 36, 30)
game.spawnXY("archer", 36, 30)
game.spawnXY("archer", 36, 30)
game.spawnXY("archer", 36, 30)
game.spawnXY("archer", 36, 30)
game.spawnXY("archer", 36, 30)
game.spawnXY("archer", 36, 30)
game.spawnXY("archer", 36, 30)
game.spawnXY("archer", 36, 30)
game.spawnXY("archer", 36, 30)
game.spawnXY("archer", 36, 30)
game.spawnXY("archer", 36, 30)
game.spawnXY("soldier", 36, 30)
game.spawnXY("soldier", 36, 30)
game.spawnXY("soldier", 36, 30)
game.spawnXY("soldier", 36, 30)
game.spawnXY("soldier", 36, 30)
game.spawnXY("soldier", 36, 30)
game.spawnXY("soldier", 36, 30)
game.spawnXY("soldier", 36, 30)
game.spawnXY("soldier", 36, 30)
game.spawnXY("soldier", 36, 30)
game.spawnXY("soldier", 36, 30)
game.spawnXY("soldier", 36, 30)
game.addManualGoal("Kill all enemies")=someGoal
def onDefeat(event):
    unit = event.target
    if unit.type == "ogre":
        # Set the bossGoal.success to True
        hero.say("Boom, baby!!")
        od+=1
    if od <=20:
        someGoal.success=True
    if someGoal.success:
        hero.say("Killed dem ogres!")

I also got an error like that except it says I need a valid string when my code is flawless

function randomInteger(){
db.add(“goldcoins”, 30);
db.add(“mushrooms”, 30);
db.add(“gems”, 30);
var y = game.randomInteger(8, 72);
var x = game.randomInteger(10, 57);
var goldcoin = game.spawnXY(“gold-coin”, x, y);
var gem = game.spawnXY(“gem”, x, y);
var mushroom = game.spawnXY(“mushroom”, x, y);
}
game.spawnXY(“forest”, 72, 25);
game.spawnXY(“forest”, 64, 25);
game.spawnXY(“forest”, 64, 18);
game.spawnXY(“forest”, 48, 18);
game.spawnXY(“forest”, 48, 25);
game.spawnXY(“forest”, 48, 30);
game.spawnXY(“forest”, 48, 35);
game.spawnXY(“forest”, 32, 18);
game.spawnXY(“forest”, 32, 25);
game.spawnXY(“forest”, 32, 30);
game.spawnXY(“forest”, 32, 35);
game.spawnXY(“forest”, 16, 18);
game.spawnXY(“forest”, 16, 25);
game.spawnXY(“forest”, 8, 25);
game.spawnXY(“forest”, 56, 37);
game.spawnXY(“forest”, 64, 37);
game.spawnXY(“forest”, 72, 37);
game.spawnXY(“forest”, 24, 37);
game.spawnXY(“forest”, 16, 37);
game.spawnXY(“forest”, 8, 37);
game.spawnXY(“forest”, 32, 50);
game.spawnXY(“forest”, 48, 50);
game.spawnXY(“forest”, 32, 53);
game.spawnXY(“forest”, 32, 59);
game.spawnXY(“forest”, 48, 53);
game.spawnXY(“forest”, 48, 59);
var defeated = game.addDefeatGoal(25);
var collected = game.addCollectGoal(25);
game.addMoveGoalXY(40, 61);
game.addMoveGoalXY(73, 31);
game.addMoveGoalXY(6, 31);
var score = game.addScoreGoal(90);
ui.track(game, “defeated”);
ui.track(game, “collected”);
ui.track(game, “collected”);
var steve = game.spawnPlayerXY(‘captain’, 72, 18);
var generator1 = game.spawnXY(“generator”, 8, 58);
var generator2 = game.spawnXY(“generator”, 8, 48);
var generator3 = game.spawnXY(“generator”, 72, 58);
var generator4 = game.spawnXY(“generator”, 72, 48);
game.spawnXY(“scout”, 24, 26);
game.spawnXY(“scout”, 24, 24);
game.spawnXY(“scout”, 24, 22);
game.spawnXY(“scout”, 56, 26);
game.spawnXY(“scout”, 56, 24);
game.spawnXY(“scout”, 56, 22);
generator1.spawnType = “skeleton”;
generator1.spawnDelay = 7;
generator1.spawnAI = “AttacksNearest”;
generator2.spawnType = “ogre-F”;
generator2.spawnDelay = 7;
generator2.spawnAI = “AttacksNearest”;
generator3.spawnType = “thrower”;
generator3.spawnDelay = 7;
generator3.spawnAI = “AttacksNearest”;
generator4.spawnType = “ogre”;
generator4.spawnDelay = 7;
generator4.spawnAI = “AttacksNearest”;
if(game.collected ==“gem”){
game.collected-=1;
game.collected-=5;
}
if(game.collected ==“gold-coin”){
game.collected +=1;
game.score +=10;
}
if(game.collected ==“mushroom”){
game.collected ==1;
game.score ==5;
}
var trap1 = game.spawnXY(“fire-spewer”, 40, 50);
trap1.direction = “horizontal”;
var trap2 = game.spawnXY(“fire-spewer”, 40, 57);
trap2.direction = “horizontal”;

please format your code correctly

what is that supposed to mean

click the </> button and paste your code into the triple quotes.

what the hell does that mean

just

type or paste code here

use the <> button at the top of your typing thing

Click on the button I circled and then type or paste your code there

and also please don’t revive topics that are 2 years old