Have you read hints for this level? You are trying to use time as an argument. The logic should time independent. Watch for the nearest friend position only.
Well done for completing the level, but please could you not post working code. It ruins it for others.
So could you delete it (edit your post and delete the part with the code) and thank you for giving the advice, you can keep that part. It’s just that it’s better to help people understand without telling them the answer.
Thanks
Danny