Keeping Time: Collecting coins

I am currently stuck on the level, keeping time. Here is my code

nearest = self.findNearest(self.findEnemies())
# If it’s the first 10 seconds, fight.
if < 10:
# Else, if it’s the first 30 seconds, collect coins.
elif < 30:
item = self.findItems()
self.moveXY(item.pos.x , item.pos.y)
# After 30 seconds, join the raid!

On the collecting coin part, I keep getting a debug message that says,"pos was null. use a null check before accessing properties. Can somebody please help?

You need to use an if statement

Hello, Clambosham, and please read the FAQ on instructions how to format your code.
Surround your code vertically, above and below in triple backticks (the thing above tab)
Use if item: First, to clarify that there actually IS an item before checking the item.pos
Also, why don’t you use self.findNearest(self.findItems)) instead of self.findItems(),
as self.findItems() just finds listed items from the array, which can be further away.

1 Like

Thank you for the help.

no problem! :slight_smile: