A Star Grid Pathfinding

I’m trying to implement A* pathfinding but i keep getting an infinite loop error.