https://gyazo.com/31ca01cf34b7e1fb7a933ccc59f428d8

Red point: Start point

Blue line: The path Pathfinding script draw

Black point: End point

And it just stays at the end of blue, script continues to work but does not continue it's way to end.

What would cause this?

	for i = 1,#Next do
		if Next[i].Value.Name ~= "Water" then
			NewDist = Cost[Current] + (Next[i].Value.Position - Current.Value.Position).magnitude
			if Cost[Next[i].Value] == nil or NewDist < Cost[Next[i]] then
				print(i)
				print(Next[i].Value)
				print(End.Value)
				if Next[i].Value == End.Value then
					Cost[End] = Cost[Current] + 1
					CameFrom[End] = Current
					break
				end
				if (Next[i].Value.Position-End.Value.Position).magnitude < 11 then
					Cost[End] = Cost[Current] + 2
					CameFrom[Next[i]] = Current
					CameFrom[End] = Next[i]
					break
				end
				Cost[Next[i]] = NewDist
				Priority = (End.Value.Position - Next[i].Value.Position).magnitude
				Frontier[table.getn(Frontier)+1] = {Priority,Next[i]}
				Frontier = PriorityQueue(Frontier)
				Current.Value.BrickColor = BrickColor.Random()
			end
		end
	end

For short, frontier table is front tiles that hasn't checked yet, Next is neighbor of Current, Current is currently checked tile, Cost shows how much tiles have been passed since Start, CameFrom shows which every tile comes from. If there is a bug, that's in this.