Game Dev 2 Final project HELP

i dont understand the code and keep forgetting how to define or do game.setGoalState(onDefeat(), True) this is my code pls help

pls send suggestions!!!

# Create your own game!





player = game.spawnPlayerXY("captain", 60, 61)
def onCollect(event):
    player = event.target
    item = event.other
    # If the item's type is "mushroom":
    if item.type == "mushroom":
        # Increase the game.score by 1.
        game.mushroom += 1
        pass
    # If the type is "mushroom", then increase game.score .
def onDefeat(event):
    if player.defeat:
        game.defeated += 1
    



game.setGoalState(onDefeat(), True)     
player.on("collect", onCollect)
spawner = game.spawnXY("generator", 15, 12)
spawner.maxHealth = 90000
spawner.spawnType = "mushroom"
spawner.spawnDelay = 3
event = ui.track("defeated")
ui.track(game,"mushroom")
ui.track(game, "time")
ui.track(game,"defeated")

# Add at least one goal!
game.addCollectGoal(10)
goal1 = game.addDefeatGoal(3)
game.addSurviveGoal(40)
player.maxHealth = 2000
player.maxSpeed = 100
player.attackDamage = 4000
# Spawn objects into the game with spawnXY()
game.spawnXY("fence", 11, 12)
game.spawnXY("fence", 11, 12)
game.spawnXY("fence", 11, 12)
game.spawnXY("fence", 11, 12)
game.spawnXY("fence", 11, 12)
game.spawnXY("fence", 11, 12)
game.spawnXY("fence", 11, 12)
game.spawnXY("fence", 11, 12)
game.spawnXY("fence", 11, 12)
game.spawnMaze("forest", 5)
# Spawn a monster "generator" in the center:
g1 = game.spawnXY("generator", 36, 30)
# Set the generator spawnType to “scout”.
g1.spawnType = "scout"
# Set the generator spawnDelay to 6 (or greater).
g1.spawnDelay = 3

    


        
    

please help w/ this i dont know what is wrong with my code!!! :weary: :weary: :weary:

Hi @Kaeley_Sieben_Dinh , welcome to the Discourse!
Thanks for formatting your code correctly.

So, here, you’re trying to use the onDefeat() function to set a goal to completed, right?
Could you explain why you want to set this particular goal to “True”, and what the goal is for?